954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

search code not working!!!

any1 help, basically iv wrote the code to search for a client name in a database(in access) and this is the code: Private Sub BtnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
'search
If txtSearch.Text = "" Then MsgBox("Please type Client Name", MsgBoxStyle.Critical, "Enter Text") : Exit Sub

Dim MYDA As OleDbDataAdapter1 = New OleDbDataAdapter()
Dim MYDS As DataSet = New DataSet()

RS = New ADODB.Recordset()
RS.Open("SELECT * FROM CLIENT WHERE NAME LIKE '" & txtSearch.Text & "%' ", CN, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic)

MYDA.Fill(MYDS, RS, "NAME")
DataGrid1.DataSource = MYDS.Tables(0)
End Sub

End Class
but it underlines the "OleDbDataAdapter1" in theDim MYDA As OleDbDataAdapter1 =. ....... but i dont know why as that is what my dataAdapter is called??
please help, id be very grateful!!!!!

shelly121
Newbie Poster
17 posts since Feb 2005
Reputation Points: 10
Solved Threads: 0
 

Try adding these imports statements at the top before anything else:

Imports System()
Imports System.Data()
Imports System.Data.Oledb()

If you do not add those imports statements, then when you declare your dataadapter you will have to do something like this:

Dim MYDA As System.Data.Oledb.OleDbDataAdapter1 = New OleDbDataAdapter()

Chester

cpopham
Junior Poster in Training
65 posts since Mar 2005
Reputation Points: 10
Solved Threads: 0
 

hey thanks CPOPHAM for replyin, i have actually sorted out all of the problems i had, but am grateful fo ya help anyway!!

shelly121
Newbie Poster
17 posts since Feb 2005
Reputation Points: 10
Solved Threads: 0
 

I am glad that you got everything to work out. I just joined the forums.

Chester

cpopham
Junior Poster in Training
65 posts since Mar 2005
Reputation Points: 10
Solved Threads: 0
 
any1 help, basically iv wrote the code to search for a client name in a database(in access) and this is the code: but it underlines the "OleDbDataAdapter1" in the but i dont know why as that is what my dataAdapter is called?? please help, id be very grateful!!!!!

try using SQL rather than using multiple codes...
in your adodc properties, find the tab that contains the cmdunknown, i can't remember exactly where that place is...
then check SQl and type:
Select * from (name of table of the database)
ex Select * from emp
this makes the form connected to the database...
then create a textbox which you will input the search word
next, create a search command button...
type this command to be executed...
"Select * from (name of table) where (name of data to be seached eg. REG_NO) like '" & txtSEARCH.Text & "%" & "'"
this makes the program search the word which contains the words or letters that is in the text box...
i hope i helped you...

Live_eviL
Newbie Poster
1 post since Mar 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You