I am having trouble writing the data from my web form to the ms access database I created.
Here is the code I have:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim MySQL As String = "Insert into Table1 (ID, FName, LName) values(@ID, @Fname, @Lname)"
Dim myConn As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source= C:\Inetpub\wwwroot\db1.mdb")
Dim Cmd As New OleDbCommand(MySQL, myConn)
Cmd.Parameters.Add(New OleDbParameter("@ID", txtID.Text))
Cmd.Parameters.Add(New OleDbParameter("@Fname", txtFName.Text))
Cmd.Parameters.Add(New OleDbParameter("@Lname", txtLName.Text))
myConn.Open()
Cmd.ExecuteNonQuery()
myConn.Close()
BindData()
End Sub
Sub BindData()
Dim MySQL As String = "Select * from Table1"
Dim myConn As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source= C:\Inetpub\wwwroot\db1.mdb")
Dim ds As DataSet = New DataSet
Dim Cmd As New OleDbDataAdapter(MySQL, myConn)
Cmd.Fill(ds, "Table1")
myConn.Close()
End Sub
Here is the error that I get:
Operation must use an updateable query.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.OleDb.OleDbException: Operation must use an updateable query.
Source Error:
Line 95: myConn.Open()
Line 96: Cmd.ExecuteNonQuery()
Line 97: myConn.Close()
Source File: c:\inetpub\wwwroot\Test1\WebForm1.aspx.
vb Line: 96
Please Help!