Click here to Skip to main content
15,844,498 members

Comments by ionline4u (Top 7 by date)

ionline4u 29-Jun-14 12:29pm View    
I have update my code but it still give me error "No value given for one or more required parameters."
The Code is given below

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

Dim cmd1 As New OleDbCommand
Dim adapter1 As New OleDbDataAdapter
Dim dt As New DataTable

con.Open()
cmd1.Connection = con
cmd1.CommandText = "SELECT EleMeeterNo FROM SrceElectricity WHERE Home/Office ='" & ComboBox1.Text & "'"
cmd1.CommandType = CommandType.Text
adapter1.SelectCommand = cmd1
adapter1.Fill(dt)
ComboBox2.DataSource = dt
ComboBox2.ValueMember = "Home/Office"
ComboBox2.DisplayMember = "Home/Office"

End Sub
ionline4u 29-Jun-14 8:02am View    
Deleted
I have made some changes according to your instruction.but when i select any item in the 1st combobox ,the 2nd combobox shows only 1st item .The code i have update is given below.

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

Dim dt As New DataTable
Dim cmd1 As OleDbCommand = New OleDbCommand("SELECT * FROM SrceElectricity", con)
Dim mda1 As OleDbDataAdapter = New OleDbDataAdapter(cmd)

cmd.Connection = con
cmd.CommandText = "SELECT EleMeeterNo FROM SrceElectricity WHERE Home/Office ='" & ComboBox1.Text & "'"
cmd.CommandType = CommandType.Text
mda1.SelectCommand = (cmd1)
mda1.Fill(dt)
ComboBox2.DataSource = dt
ComboBox2.ValueMember = "EleMeeterNo"
ComboBox2.DisplayMember = "EleMeeterNo"

End Sub
ionline4u 13-Jun-14 14:17pm View    
but my project is in vb.net Please give me the code examples in VB.
ionline4u 12-Jun-14 14:54pm View    
yes you are correct .it is datagridview. Please guide me.
ionline4u 12-Jun-14 0:30am View    
it is vb form with MS Access db.i put it through toolbox and bend it to ms access to ms access table.Now i Just required a guide line to save data from this table into Access.