hi im having problem with my simple library i dont know what is the code to search a record in the data grid im ung adodc .. any one kindly help with my project only the search code.. is my problem so how to search in the data grid?
here's the preview

Recommended Answers

All 16 Replies

The datagrid gets its result set from the database so maybe you may want to try searching the database table and if the result is found, you point to the record on the datagrid.

so how to do that? sorry newbie in programming.

What DBMS are you working with?

im using microsoft access.. its only for school project ,

Imports System.Data.OleDb

Public Class Form1 Inherits System.Windows.Forms.Form

Dim cn As OleDbConnection
Dim cmd As OleDbCommand
Dim dr As OleDbDataReader

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As_
System.EventArgs) Handles Button1.Click

    cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;_
	Data Source=C:\emp.mdb;")
'provider to be used when working with access database

cn.Open() 'open connection 
cmd = New OleDbCommand("select * from table1 where columnname = '"+ textbox1.text + "'", cn)

dr = cmd.ExecuteReader
While dr.Read()
' loading data into datagrid
End While

Catch ex as exception 

End Try



End Sub

End Class

so i put that code into the search command button right?.. i have a combo box.. to choose whether its tittle or book author,, thanks i gonna check it out
btw here my project that i am talking about sir.

ahhhh where to put that codes you give sir?., look at my project can u help me finish that?.

Follow all events accordingly. The codes under the Button1_Click event should be pasted in your search button

sir, compile error sub or function not defined. i put the code in the search command button.
whats the problem now?

you're not to copy all the codes under the search button. The codes under the Form1_load should be placed under your own form load event and those under the button1_click even t should be under your search button. It works well for me without errors

sir can u put the codes u gave for me?. then re upload it. pls? thanks in advanced sorry im newbie in vb ., i can't understand the codes u gave,

sir can u arrange the code u gave for me.. and then re upload it. sorry im cant understand the code u gave cause im new to vb.. download my proj and re upload it please? thanks.

sir i follow the what u said.. and i got too many error.. ahhh why is that? "compile error list seperator or ) "

If I'm not mistaken, your first print screen shows VB6 in the background.
Can you please let us know what VB you are using for this project?

im using vb6 sir..

Friend, I don't think Netcode's solution will work for you, as it is written for VB.Net (This post has been created in the VB.Net portion of the site)

Please search the Visual Basic 4/5/6 section of the forum for a solution to your question and if you can't find what you are looking for then create a thread in that section. I'm sure your answer will be answered quickly and correctly if you post in the appropriate section.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.