|
-
May 4th, 2009, 11:02 AM
#1
Thread Starter
Junior Member
[RESOLVED] DataGridView Error
Hi,
I am obviously doing something wrong. I am trying to hook up a search button so the user can search the database by last name. I have a textbox where the user types in the last name and then clicks search. Problem is that I keep getting an error that says (No value given for one or more required parameters.) referring to line- da.Fill(ds,"EmpAccessInfo") - when I use the following string:
strSearch = "SELECT * FROM EmpAccessInfo WHERE LastN LIKE " & txtSRCH_LN.Text
But it works fine and displays ALL the records when I use:
strSearch = "SELECT * FROM EmpAccessInfo"
Here is my code:
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
Dim con As New OleDb.OleDbConnection
Dim ds As New DataSet
Dim da As OleDb.OleDbDataAdapter
Dim strSearch As String
con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\AppAccess_tst3.mdb"
con.Open()
strSearch = "SELECT * FROM EmpAccessInfo WHERE LastN LIKE " & txtSRCH_LN.Text
da = New OleDb.OleDbDataAdapter(strSearch, con)
da.Fill(ds, "EmpAccessInfo")
DataGridView1.DataSource = ds.Tables("EmpAccessInfo") ''DefaultViewManager
con.Close()
End Sub
Not sure what I am doing wrong. Any help would be great.
Thanks!
Mac
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|