嘿,晚上好,谁能告诉我我的代码有什么问题?我收到如下所示的“操作不可更新”错误
Server Error in '/' Application.
Operation must use an updateable query.
Description: An unhandled exception occurred during the execution of the current
webrequest. 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 20: cmd.Parameters.AddWithValue("paswords", TextBox4.Text)
Line 21: conn.Open()
Line 22: cmd.ExecuteNonQuery()
Line 23: End Using
Line 24: End Using
我的代码是
Imports System.Web.Security
Imports System.Data
Imports System.Data.OleDb
Imports System.Configuration
Imports System.Web.Configuration
Partial Class Registration
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|onlineregistration.mdb"
Dim SqlString As String = "Insert Into registration (firtsname, telephone, email, paswords) Values (?,?,?,?)"
Using conn As New OleDbConnection(ConnString)
Using cmd As New OleDbCommand(SqlString, conn)
cmd.CommandType = CommandType.Text
cmd.Parameters.AddWithValue("firtsname", TextBox1.Text)
cmd.Parameters.AddWithValue("telephone", TextBox2.Text)
cmd.Parameters.AddWithValue("email", TextBox3.Text)
cmd.Parameters.AddWithValue("paswords", TextBox4.Text)
conn.Open()
cmd.ExecuteScalar()
End Using
End Using
End Sub
End Class