Click here to Skip to main content
15,886,815 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when i was click on button then message box show message "cannot find table0."
what does it means ???how can i solve this problem ????
VB
Private Sub butsea_Click(sender As Object, e As EventArgs) Handles butsea.Click

        Dim dset As New DataSet
        Dim da As SqlDataAdapter
        Dim myCmd As New SqlCommand

        Try
       myConn.ConnectionString = "Data Source=THEONE\PARTH;Initial Catalog=testdatabase;Integrated Security=True;"
            myConn.Open()

            Dim avalue As String = (InputBox("Input Student Id", "Search Student")).ToString
            txt_id.Text = avalue
            da = New SqlDataAdapter("SELECT * FROM studentdetails where student_id= '" & txt_id.Text & "", myConn)
            If dset.Tables(0).Rows.Count > 0 Then
                MsgBox("Record Found")
            Else
                MsgBox("No Record Found")
            End If
           
        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            myConn.Close()
        End Try

    End Sub
Posted
Comments
abbaspirmoradi 24-Aug-13 12:20pm    
you must fill dataset with SqlDataAdapter

You declare a DataSet at the top of your method, but you don't actually connect it with the database via the DataAdapter! Try adding the middle line:
SQL
da = New SqlDataAdapter("SELECT * FROM studentdetails where student_id= '" & txt_id.Text & "", myConn)
da.Fill(dset)
If dset.Tables(0).Rows.Count > 0 Then
 
Share this answer
 
Comments
Parth Akbari 24-Aug-13 12:42pm    
thx,
now i want to extract every single value from database and display value (single value)in textbox ,
use above same code method....
OriginalGriff 24-Aug-13 12:45pm    
And?
Your difficulty doing this is? :laugh:
Post it as a new question - it isn't directly related to the original question, so it needs a new one - with rather better information than a single sentence!
C#
Private Sub butsea_Click(sender As Object, e As EventArgs) Handles butsea.Click
 
        Dim dset As New DataSet
        Dim da As SqlDataAdapter
        Dim myCmd As New SqlCommand
 
        Try
       myConn.ConnectionString = "Data Source=THEONE\PARTH;Initial Catalog=testdatabase;Integrated Security=True;"
            myConn.Open()
 
            Dim avalue As String = (InputBox("Input Student Id", "Search Student")).ToString
            txt_id.Text = avalue
            da = New SqlDataAdapter("SELECT * FROM studentdetails where student_id= '" & txt_id.Text & "", myConn)
            da.Fill(dset)
            If dset.Tables(0).Rows.Count > 0 Then
                MsgBox("Record Found")
            Else
                MsgBox("No Record Found")
            End If
           
        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            myConn.Close()
        End Try
 
    End Sub
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900