Question the microsoft jet database engine could not find the object "yns"

Abdalltif

New member
Joined
Dec 13, 2013
Messages
4
Programming Experience
1-3
this message appear when i try to insert record from vb.NET

VB.NET:
          Public conn As New OleDbConnection
          Public x As String = "provider=microsoft.jet.oledb.4.0; data source=" & Application.StartupPath & "\yns.mdb"
          conn.ConnectionString = x
          Try            
            conn.Open()
            Dim cmdInsert As New OleDbCommand
            cmdInsert.Connection = conn
            cmdInsert.CommandText = "INSERT into yns VALUES(@x1,@x2)"
            cmdInsert.Parameters.AddWithValue("@x1", t1.Text)
            cmdInsert.Parameters.AddWithValue("@x2", t2.Text)
            cmdInsert.ExecuteNonQuery()
Is there something wrong with OledbConnection ?
 
Firstly, if the database is in the program folder then the proper way to address it is like this:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\yns.mdb
As for the question, if the call to Open works then there's nothing wrong with the connection. The error occurs when you execute the command so the issue is with the command. There is no table in your database named 'yns'.
 
Back
Top