sir/madam..
i am a beginner with .net i am trying to get data from dropdown list(in which name is bound) and i want to display id in a textbox ...my table contains parameters name,id and item...
my problem is an error message "parameter name is not in the parameter oledb connection"..
can anybody help me??
thanks to all...
Protected Sub ddl1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddl1.SelectedIndexChanged Dim Conn As OleDbConnection Dim command1 As OleDbCommand Conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Administrator.HOME\My Documents\Visual Studio 2008\WebSites\production\otentry.mdb;") command1 = New OleDbCommand("SELECT * FROM [ofotentry] WHERE ([@name]) ='" & ddl1.SelectedItem.Text & "'", Conn) command1.Parameters("@name").Value = ddl1.SelectedItem.Text Conn.Open() command1.ExecuteNonQuery() If Not IsDBNull(command1.Parameters("@name").Value) Then TextBox2.Text = command1.Parameters("@tid").Value End If Conn.Close() End Sub
This is not the best way to get an ID from ComboBox.
Try this code:
Add this in the Load event of your form
This assumes that the name of your combobox is ComboBox1
Pages
Add new comment