hi,
just trying to put together my first vb express 2008 application (after using vb6 for several years)
i want to get values from access table (based on selection from two combo boxes) and insert them to text boxes:
here is my code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
On Error Resume Next
Dim con As New OleDb.OleDbConnection
Dim ds As New DataSet
Dim da As OleDb.OleDbDataAdapter
Dim sql As String
Dim mystate As String
Dim mycounty As String
If Len(ComboBox1.Text) < 2 Then
MsgBox("Select state first.")
Exit Sub
End If
If Len(ComboBox2.Text) < 3 Then
MsgBox("Select county first.")
Exit Sub
End If
mystate = "'" & ComboBox1.Text & "'"
mycounty = "'" & ComboBox2.Text & "'"
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = c:\zcs\zcs\ldata.mdb"
con.Open()
sql = "select, [W] from snowload where [st]=" & mystate & " and [county]=" & mycounty & ""
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "s")
con.Close()
TextBox1.Text = ds.Tables("s").Columns(0).ToString
da.Fill(ds, "w")
TextBox2.Text = ds.Tables("w").Columns(1).ToString
End Sub
i am getting an error "No value given for one or more required parameters" for da.Fill(ds, "s")
please advice
just trying to put together my first vb express 2008 application (after using vb6 for several years)
i want to get values from access table (based on selection from two combo boxes) and insert them to text boxes:
here is my code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
On Error Resume Next
Dim con As New OleDb.OleDbConnection
Dim ds As New DataSet
Dim da As OleDb.OleDbDataAdapter
Dim sql As String
Dim mystate As String
Dim mycounty As String
If Len(ComboBox1.Text) < 2 Then
MsgBox("Select state first.")
Exit Sub
End If
If Len(ComboBox2.Text) < 3 Then
MsgBox("Select county first.")
Exit Sub
End If
mystate = "'" & ComboBox1.Text & "'"
mycounty = "'" & ComboBox2.Text & "'"
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = c:\zcs\zcs\ldata.mdb"
con.Open()
sql = "select
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "s")
con.Close()
TextBox1.Text = ds.Tables("s").Columns(0).ToString
da.Fill(ds, "w")
TextBox2.Text = ds.Tables("w").Columns(1).ToString
End Sub
i am getting an error "No value given for one or more required parameters" for da.Fill(ds, "s")
please advice