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

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

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

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

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

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

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

in select(search

sCHOOL

Be a part of the DaniWeb community

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