Click here to Skip to main content
15,915,019 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hie!

I am trying to add item in combobox at runtime from database for that i am writing the following code :

Dim cn As OleDbConnection
Dim cmd As System.Data.OleDb.OleDbCommand
Dim da As OleDbDataAdapter
Dim dr As Data.OleDb.OleDbDataReader
Dim str As String
Dim icount As Integer
Dim ds As DataSet


in form_laod event


cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\panchani\Documents\Visual Studio 2005\Transport.mdb")
cmbName.Items.Clear()
cmd.Connection = cn
cmd.CommandText = "select nature_of_good from item_master"
cn.Open()
dr = cmd.ExecuteReader()
cmbName.Items.Clear()
While (dr.Read)
cmbName.Items.Add(dr("name"))
End While

dr.Close()



but when i run this form it will dispaly error on line

dr=cmd.Excutereader()

Error : NO Value is given for one or more parameters

Please Help Me !..................Thank you
Posted

1 solution

in your sql query
cmd.CommandText = "select nature_of_good from item_master"


parameter name doesn't exists
cmbName.Items.Add(dr("name"))
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900