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

Search Button..Plz Help

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

geetajlo
Junior Poster in Training
72 posts since Sep 2007
Reputation Points: 8
Solved Threads: 0
 

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

binoj_daniel
Practically a Master Poster
645 posts since Dec 2006
Reputation Points: 25
Solved Threads: 18
 

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
-----------

preetham.saroja
Junior Poster in Training
82 posts since Jun 2007
Reputation Points: 5
Solved Threads: 1
 

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

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
nduduzo
Newbie Poster
5 posts since Aug 2009
Reputation Points: 10
Solved Threads: 0
 

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....

ayame2012
Newbie Poster
2 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
 
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

nduduzo
Newbie Poster
5 posts since Aug 2009
Reputation Points: 10
Solved Threads: 0
 

i need to know code in select(search),insert,update and delete to sql 2005 data base.plzzz help me.

Nuski Dineth
Newbie Poster
1 post since Aug 2011
Reputation Points: 10
Solved Threads: 0
 
adam_k
Master Poster
795 posts since Jun 2011
Reputation Points: 256
Solved Threads: 148
 
Netcode
Veteran Poster
1,021 posts since Jun 2009
Reputation Points: 43
Solved Threads: 67
 

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

bentotxkie
Newbie Poster
1 post since Dec 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You