Can ne one of u plz tell me how to search a particular record in the database ?
my prob is that when i enter say an ID / Name it should search into database for the same and accordingly if the record is found my cmdbutton will be enabled and vice versa.....
am using vb.net 2005 and sql server 2000 . Kindly help me soon......am wating......its urgent

This an example :

Dim conn As SqlConnection
    Dim cmdCustomer As New SqlCommand
    Dim daCustomer As New SqlDataAdapter
    Dim dsCustomer As New DataSet
    Dim dtCustomer As New DataTable

    conn = GetConnect()
    conn.Open()
    Try
        dsCustomer.Clear()
        dtCustomer.Clear()
        cmdCustomer = conn.CreateCommand
        cmdCustomer.CommandText = "SELECT * FROM Customer where IDCustomer = '" & Trim(txtIdCustomer) & "'"
        daCustomer.SelectCommand = cmdCustomer
        daCustomer.Fill(dsCustomer, "Customer")
        dtCustomer = dsCustomer.Tables("Customer")

        If (dtCustomer.Rows.Count > 0) Then
            txtNamaCustomer.Text = dtCustomer.Rows(0).Item(1)
	    cmdButton.enable = False
        Else
            MsgBox("Can't Find Id customer!!")
            txtPlatNo.Focus()
        End If

    Catch ex As Exception
        MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OKOnly, "Connection Error !!")
    End Try
    conn.Close()

thanks dude, i will surely try hp it works....
btw i am during using OLEDB ie. ADO.NET instead of SQL client.....

This an example :

Dim conn As SqlConnection
    Dim cmdCustomer As New SqlCommand
    Dim daCustomer As New SqlDataAdapter
    Dim dsCustomer As New DataSet
    Dim dtCustomer As New DataTable

    conn = GetConnect()
    conn.Open()
    Try
        dsCustomer.Clear()
        dtCustomer.Clear()
        cmdCustomer = conn.CreateCommand
        cmdCustomer.CommandText = "SELECT * FROM Customer where IDCustomer = '" & Trim(txtIdCustomer) & "'"
        daCustomer.SelectCommand = cmdCustomer
        daCustomer.Fill(dsCustomer, "Customer")
        dtCustomer = dsCustomer.Tables("Customer")

        If (dtCustomer.Rows.Count > 0) Then
            txtNamaCustomer.Text = dtCustomer.Rows(0).Item(1)
	    cmdButton.enable = False
        Else
            MsgBox("Can't Find Id customer!!")
            txtPlatNo.Focus()
        End If

    Catch ex As Exception
        MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OKOnly, "Connection Error !!")
    End Try
    conn.Close()

THANKS IT WORKED !!

thanks dude, i will surely try hp it works....
btw i am during using OLEDB ie. ADO.NET instead of SQL client.....

Specify the problem clearly so i can help you out
Basically we are using the data adapter dataset and datatable to collect the values from the database and then we bind the control with the datatable property called as row Please send ur query in detail so i can help you out

okie...here it goes, i am not using sql client. am using this piece of code :

Dim dbconnection As New OleDbConnection
Dim dbadapter As OleDbDataAdapter
Dim connectionstring As String = "

i import these files :
Imports System.Data.OleDb
Imports System.Data.OleDb.OleDbConnection

how can u elaborate ? actually i am not getting the desired out put....check the thread above named "Correct Me" in which i have explained the problem clearly...hp u will get me right this time....am novice at vb.net so taking time ...plz co-operate !

awating your favourable reply !

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.