Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
2 Listboxes and database
#7
I have Made a database of (ID,Name.Age) and do the following codes , it doesn't work , Please guide me what can I do
Note :- I am not good in Programming

[code2=vbnet]Imports System.Data.SqlClient
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

ListBox2.Items.Add(ListBox1.SelectedItem)
ListBox1.Items.Remove(ListBox1.SelectedItem)
End Sub
Public Sub calculate()
Dim IDS As New List(Of Double)
Dim Names As New List(Of String)
Dim ages As New List(Of Double)

For Each item In ListBox2.Items
Dim itemName As String = item.ToString
Dim ID As Double
Dim age As Double
Dim conn As New SqlConnection("Data Source=C:\Users\QaziNasir\documents\visual studio 2010\Projects\NSfile\NSfile\NDatabase.sdf")
Dim sqlquery As String = "SELECT * From NSTable = '" & itemName & "'"
Dim command As New SqlCommand
command.Connection = conn
command.CommandText = sqlquery
Dim adapter As New SqlDataAdapter
adapter.SelectCommand = command
Dim Data As SqlDataReader
conn.Open()
Data = command.ExecuteReader
While Data.Read
ID = CDbl(Data(1))
Name = CDbl(Data(2))
age = CDbl(Data(3))
End While
Data.Close()
conn.Close()

IDS.Add(ID)
ages.Add(age)
Names.Add(itemName)
Next
End Sub
End Class[/code2]


Messages In This Thread
2 Listboxes and database - by qazinasir - 07-20-2012, 08:46 PM
Re: 2 Listboxes and database - by qazinasir - 07-20-2012, 09:57 PM
Re: 2 Listboxes and database - by qazinasir - 07-21-2012, 12:36 AM
Re: 2 Listboxes and database - by qazinasir - 07-22-2012, 02:21 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  VB2010 & MS Access Database kismetgerald 3 13,916 01-10-2012, 10:35 PM
Last Post: kismetgerald
  others can't connect to online database Stefanvp 3 13,722 08-14-2011, 09:46 PM
Last Post: brandonio21
  connect to online database elnashar77 3 13,831 08-09-2011, 01:27 PM
Last Post: brandonio21
  DataBase - Login - Not Working Murcs 4 16,226 07-02-2011, 09:46 AM
Last Post: brandonio21

Forum Jump:


Users browsing this thread: 1 Guest(s)