Trying to Insert Text to Access Database with ExecuteNonQueryin VB
- by user3673701
I'm working on this feature were i save text from a textbox on my form to a access database file. With the click on my "store" button I want to save the text in the corresponding textbox fields to the fields in my access database for searching and retrieving purposes. Im doing this in VB
The problem I run into is the INSERT TO error with my "store" button
Any help or insight as to why im getting error would be greatly appreciated.
here is my code:
Dim con As System.Data.OleDb.OleDbConnection
Dim cmd As System.Data.OleDb.OleDbCommand
Dim dr As System.Data.OleDb.OleDbDataReader
Dim sqlStr As String
Private Sub btnStore_Click(sender As Object, e As EventArgs) Handles btnStore.Click
con = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Eric\Documents\SPC1.2.accdb")
con.Open()
MsgBox("Initialized")
sqlStr = "INSERT INTO Master FADV Calll info (First Name, Last Name,
Phone Number, Email, User Id) values (" & txtFirstName.Text & " ' ,'" &
txtLastName.Text & "','" & txtPhone.Text & "', '" & txtEmail.Text & "', '" &
txtUserID.Text & "', '" & txtOtherOptionTxt.Text & "','"
& txtCallDetail.Text & "');"
cmd = New OleDb.OleDbCommand(sqlStr, con)
cmd.ExecuteNonQuery() <------- **IM RECIVING THE ERROR HERE**
MsgBox("Stored")
''pass ther parameter as sq; query, con " connection Obj)"
con.Close()'