| | |
Search Button..Plz Help
Please support our VB.NET advertiser: Programming Forums - DaniWeb Sister Site
![]() |
This is pretty easy to do. You can tie the DataGrid to the filter function and pass textbox as a paramter to filter records on the Grid
just paste this code:::
Protected Sub btnchk_name_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnchk_name.Click
Dim str As String = "select ID from table1 where ID = '" & txtid.Text & "'"
Dim con As String = ConfigurationManager.AppSettings("preeconn")
Dim com As New SqlCommand(str, New SqlConnection(con))
com.Connection.Open()
Dim da As New SqlDataAdapter(str, con)
Dim dr As SqlDataReader
dr = com.ExecuteReader 'where sqldatareader ain't run without using
If Not dr.Read() Then
datagrid.datasource=com.executereader()
datagrid.databind()
End If
End Sub
-----------
Protected Sub btnchk_name_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnchk_name.Click
Dim str As String = "select ID from table1 where ID = '" & txtid.Text & "'"
Dim con As String = ConfigurationManager.AppSettings("preeconn")
Dim com As New SqlCommand(str, New SqlConnection(con))
com.Connection.Open()
Dim da As New SqlDataAdapter(str, con)
Dim dr As SqlDataReader
dr = com.ExecuteReader 'where sqldatareader ain't run without using
If Not dr.Read() Then
datagrid.datasource=com.executereader()
datagrid.databind()
End If
End Sub
-----------
•
•
Join Date: Aug 2009
Posts: 2
Reputation:
Solved Threads: 0
is this code applicable to OleDb? because i've tried it Substituting with OleDb, but it seems not to work. here is my code including myDataConnectio. plz help agentely im in a tight position
VB.NET Syntax (Toggle Plain Text)
Protected Sub txtSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtSearch.Click Dim sql As String = "SELECT * FROM new_bug WHERE Status='" & txtStatus2.Text & "'" Dim cmnd As New OleDbCommand(sql, CreateOleDbConnection) Dim da As New OleDbDataAdapter(sql, CreateOleDbConnection) Dim dr As OleDbDataReader = cmnd.ExecuteReader If Not dr.Read() Then GridBugList.DataSource = cmnd.ExecuteReader() GridBugList.DataBind() End If End Sub Public Function CreateOleDbConnection() As OleDbConnection Dim myConnString As String = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + Server.MapPath("~/App_Data/bug_base.mdb") Dim myConnection As New OleDbConnection(myConnString) myConnection.Open() Return myConnection End Function
Last edited by John A; Aug 26th, 2009 at 10:11 pm. Reason: added code tags
![]() |
Similar Threads
- problem clicking on button (Perl)
- Could somebody write code for my project plz... (Visual Basic 4 / 5 / 6)
- Search code ... (Visual Basic 4 / 5 / 6)
- search record using search button from database (ASP)
- Where, oh where has my search button gone? (DaniWeb Community Feedback)
- help please cannot use search button on ie6 (Web Browsers)
Other Threads in the VB.NET Forum
- Previous Thread: Access Database + Soundex(Sound like Query)
- Next Thread: Calender extender
Views: 3630 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
.net .net2005 30minutes 2005 2008 access application arithmetic array basic binary bing button buttons c# center check code combobox component connectionstring convert crystalreport data database databasesearch datagrid datagridview design designer dissertation dissertations dissertationthesis dll dropdownlist error excel file-dialog folder ftp google hardcopy highlighting image images inline installer listview login mobile ms navigate net networking opacity output peertopeervideostreaming picturebox picturebox1 plugin port print printing problem problemwithinstallation project reports" save savedialog searchbox serial server soap sorting sql string studio syntax tcp text textbox timer toolbox trim updown usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web wpf





