943,685 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 9576
  • VB.NET RSS
Oct 16th, 2007
0

Search Button..Plz Help

Expand Post »
hi can anyone help me . when the user enter the name in a textbox and click the search button, the output should be display in the datagrid... Help plz have to submit my project in 8 days
Similar Threads
Reputation Points: 8
Solved Threads: 0
Junior Poster in Training
geetajlo is offline Offline
72 posts
since Sep 2007
Oct 16th, 2007
0

Re: Search Button..Plz Help

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
Reputation Points: 25
Solved Threads: 18
Practically a Master Poster
binoj_daniel is offline Offline
645 posts
since Dec 2006
Oct 18th, 2007
-1

Re: Search Button..Plz Help

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
-----------
Reputation Points: 5
Solved Threads: 1
Junior Poster in Training
preetham.saroja is offline Offline
82 posts
since Jun 2007
Aug 26th, 2009
0

Re: Search Button..Plz Help

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)
  1. Protected Sub txtSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtSearch.Click
  2. Dim sql As String = "SELECT * FROM new_bug WHERE Status='" & txtStatus2.Text & "'"
  3. Dim cmnd As New OleDbCommand(sql, CreateOleDbConnection)
  4. Dim da As New OleDbDataAdapter(sql, CreateOleDbConnection)
  5. Dim dr As OleDbDataReader = cmnd.ExecuteReader
  6. If Not dr.Read() Then
  7. GridBugList.DataSource = cmnd.ExecuteReader()
  8. GridBugList.DataBind()
  9. End If
  10. End Sub
  11.  
  12. Public Function CreateOleDbConnection() As OleDbConnection
  13. Dim myConnString As String = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + Server.MapPath("~/App_Data/bug_base.mdb")
  14. Dim myConnection As New OleDbConnection(myConnString)
  15. myConnection.Open()
  16. Return myConnection
  17. End Function
Last edited by John A; Aug 26th, 2009 at 10:11 pm. Reason: added code tags
Reputation Points: 10
Solved Threads: 0
Newbie Poster
nduduzo is offline Offline
4 posts
since Aug 2009
Mar 17th, 2010
0
Re: Search Button..Plz Help
hi, can you help me for our search button code. How can we tie the DataGrid to the filter function and pass textbox as a paramter to filter records on the Grid so that what we are searching will display on the data grid? Please help, we have to pass this system urgent..
Thanks and more power....
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ayame2012 is offline Offline
2 posts
since Mar 2010
Mar 17th, 2010
0

Software & web development and design

Click to Expand / Collapse  Quote originally posted by geetajlo ...
hi can anyone help me . when the user enter the name in a textbox and click the search button, the output should be display in the datagrid... Help plz have to submit my project in 8 days
Hi there
First of all you need to connect your data base to your page
Public Function CreateOleDbConnection() As OleDbConnection
Dim myConnString As String = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + Server.MapPath("~/App_Data/Training_db.mdb")
Dim myConnection As New OleDbConnection(myConnString)
myConnection.Open()
Return myConnection
End Function

Second assign you database called values to you datagrid
Public Sub SearchCourse(ByVal CourseID As String)
Try
Dim sql As String = "SELECT CourseID, CourseName, Date_From,Date_To, SeatsAvailible FROM CourseInfo WHERE CourseName='" & coursename & "'"
Dim cmnd As New OleDbCommand(sql, CreateOleDbConnection)
Dim dataset As New DataSet()
Dim adapter As New OleDbDataAdapter(cmnd)
adapter.Fill(dataset)
adapter.Dispose()
'binding you datagrid with data from you database that which you have called
GridTrainingCourse.DataSource = dataset.Tables(0)
GridTrainingCourse.DataBind()
cmnd.Dispose()
CreateOleDbConnection.Close()
Catch ex As Exception
lblNoRecords.Text = "No records found, please redefine your search"
End Try
End Sub

Third call the function/sub to clicking event of you button.

Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
'search value
Dim CourseID as string= txtSearch.Text
SearchCourse(CourseID)
End Sub
Reputation Points: 10
Solved Threads: 0
Newbie Poster
nduduzo is offline Offline
4 posts
since Aug 2009
Aug 5th, 2011
0
Re: Search Button..Plz Help
i need to know code in select(search),insert,update and delete to sql 2005 data base.plzzz help me.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Nuski Dineth is offline Offline
1 posts
since Aug 2011
Aug 5th, 2011
0
Re: Search Button..Plz Help
Reputation Points: 204
Solved Threads: 121
Practically a Master Poster
adam_k is online now Online
647 posts
since Jun 2011
Aug 5th, 2011
0
Re: Search Button..Plz Help
Last edited by Netcode; Aug 5th, 2011 at 12:42 pm.
Reputation Points: 43
Solved Threads: 67
Veteran Poster
Netcode is offline Offline
1,014 posts
since Jun 2009
Dec 21st, 2011
0
Re: Search Button..Plz Help
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bentotxkie is offline Offline
1 posts
since Dec 2011
Message:
Previous Thread in VB.NET Forum Timeline: Filtering files in directory
Next Thread in VB.NET Forum Timeline: watermark





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC