i want to populate a listbox from a sql database and foll is the code i encountered error with:
Dim con As SqlConnection
Dim cmd As SqlCommand
Dim lrd As SqlDataReader
Dim dsitemlist As New DataSet


con = New SqlConnection("Data Source=DHAVAL-PC\SQLEXPRESS;Initial Catalog=final;Integrated Security=True")
con.Open()
'cmd = New SqlCommand("select Stud_RollNo from StudentDetails", con)
Dim temp As New SqlDataAdapter
temp.Fill(dsitemlist)
ComboBox1.DataSource = dsitemlist
ComboBox1.DisplayMember = "Stud_RollNo"


MessageBox.Show("done")
con.Close()

i find error at temp.fill(dsitemlist).......
kindly help

You aren't linking the command object to the dataAdapter so your dataAdapter doesn't know what to do.

Dim temp As New SqlDataAdapter(cmd)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.