S
Sid Williams
Guest
I am using Windows 10 with Office 2016 and Visual Studio 2017. I have a simple application to save details to access database using the following code
Try
Dim sqlconn As New OleDb.OleDbConnection
Dim sqlquery As New OleDb.OleDbCommand
Dim connString As String
connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\Business.accdb"
sqlconn.ConnectionString = connString
sqlquery.Connection = sqlconn
sqlconn.Open()
sqlquery.CommandText = "INSERT INTO tbProducts(ProductName, MRP)VALUES('@ProductName', '@MRP')"
sqlquery.Parameters.AddWithValue("@ProductName", TextBox1.Text)
sqlquery.Parameters.AddWithValue("@MRP", TextBox2.Text)
sqlquery.ExecuteNonQuery()
sqlconn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
MsgBox("saved")
But I get the following error
What may be going wrong here ?
Continue reading...
Try
Dim sqlconn As New OleDb.OleDbConnection
Dim sqlquery As New OleDb.OleDbCommand
Dim connString As String
connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\Business.accdb"
sqlconn.ConnectionString = connString
sqlquery.Connection = sqlconn
sqlconn.Open()
sqlquery.CommandText = "INSERT INTO tbProducts(ProductName, MRP)VALUES('@ProductName', '@MRP')"
sqlquery.Parameters.AddWithValue("@ProductName", TextBox1.Text)
sqlquery.Parameters.AddWithValue("@MRP", TextBox2.Text)
sqlquery.ExecuteNonQuery()
sqlconn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
MsgBox("saved")
But I get the following error
What may be going wrong here ?
Continue reading...