.ExecuteNonQuery Method ERROR

france

Member
Joined
Feb 17, 2005
Messages
17
Location
CA
Programming Experience
1-3
Dim MyConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source= C:\Davenben.mdb;" & "User Id=admin;Password=;"

Dim Query As String = "SELECT * FROM login"

Dim MyConnection As New OleDbConnection(MyConn)

Dim StrInsertCommand As String = "INSERT INTO login(Username,Password)" & "VALUES(@Username, @Password)"

Dim daLog As New OleDbDataAdapter

Dim dsLog As New DataSet

Dim MyCommand As OleDbCommand = New OleDbCommand(Query, MyConnection)

Dim InsertCommand As OleDbCommand = New OleDbCommand(StrInsertCommand, MyConnection)

daLog.SelectCommand = MyCommand

daLog.InsertCommand = MyCommand

MyConnection.Open()

daLog.Fill(DataSet11)

InsertCommand.Parameters.Add(
New OleDbParameter("@Username", OleDbType.VarChar, 10)).Value = "Lacey"

InsertCommand.Parameters.Add(
New OleDbParameter("@Password", OleDbType.VarChar, 10)).Value = "geric"

InsertCommand.ExecuteNonQuery()

MyConnection.Close()

This is my code to insert in my tables however when I run it, there was an error:

"An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll

can someone help me, I am so clueless... I would really appreciate it..
 
Back
Top