I create small database and I want to show all information about the students when a techer enter
Students ID I caret my database using visual studio 2008

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim constr as new OleDb.OleDbConnection
constr.ConnectionString = "Provider=localhost;data source=C:\USERS\USER\DOCUMENTS\VISUAL STUDIO 2008\PROJECTS\APP V1.2\APP V1.2\DATABASE1.MDF"
Dim sqlstr as string=""
sqlstr="select * from Table1 where StudentID=" & Textbox1.text

       Try
            Dim ds As New DataSet
            Dim apt As New SqlDataAdapter
            apt.Dispose()
            ds.Dispose()
            apt = New SqlDataAdapter(sqlstr, constr)
            apt.Fill(ds)
            Datagridview1.DataSource = ds.Tables(0)
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        End Try 
End Sub

I keep get this error message

Error   1   Overload resolution failed because no accessible 'New' can be called with these arguments:
    'Public Sub New(selectCommandText As String, selectConnection As System.Data.SqlClient.SqlConnection)': Value of type 'System.Data.OleDb.OleDbConnection' cannot be converted to 'System.Data.SqlClient.SqlConnection'.
    'Public Sub New(selectCommandText As String, selectConnectionString As String)': Value of type 'System.Data.OleDb.OleDbConnection' cannot be converted to 'String'. C:\Users\user\Documents\Visual Studio 2008\Projects\app v1.2\app v1.2\Form1.vb  30  19  app v1.2

I would check your new statements:

Dim ds As New DataSet9.            
Dim apt As New SqlDataAdapter
apt = New SqlDataAdapter(sqlstr, constr)

As these may be looking for parameters that you are not passing in correctly.

My suspicion is on this statement:

apt = New SqlDataAdapter(sqlstr, constr)

I believe you may have your to change your parameters.
After reading the code tag, it looks like the contructor wants:

*New(selectCommandText as String, selectConnectionString as String)*

When you are passing in a string/OLEDB Connection

Which warrants the question, why are you cross calling the SQLClient and OLEDB libraries?

Comments
All that just to get to your last sentence? :)

System.Data.OleDb.OleDbConnection' cannot be converted to 'System.Data.SqlClient.SqlConnection

To be blunt about what BegginnerDev alluded to:

Which warrants the question, why are you cross calling the SQLClient and OLEDB libraries?

change: Dim constr as new OleDb.OleDbConnection

to: Dim constr As New SqlConnection

Also, why are you creating and immediately disposing the adapter and dataset?

Disposing of data objects is a good idea, but do it in the correct sequence.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
   Dim constr As New System.Data.SqlClient.SqlConnection
   constr.ConnectionString = "Provider=localhost;data source=C:\USERS\USER\DOCUMENTS\VISUAL STUDIO 2008\PROJECTS\APP V1.2\APP V1.2\DATABASE1.MDF"
   Dim sqlstr As String = "select * from Table1 where StudentID=" & TextBox1.Text
   Dim ds As New DataSet
   Dim apt As New SqlDataAdapter
   Try
      apt = New SqlDataAdapter(sqlstr, constr)
      apt.Fill(ds)
      DataGridView1.DataSource = ds.Tables(0)
   Catch ex As Exception
      MsgBox(ex.Message.ToString)
   Finally
      constr.Dispose()
      apt.Dispose()
   End Try
End Sub
This article has been dead for over six months. Start a new discussion instead.