Error msg:Operation must use an updateable query .
The codes are shown below. For this example, instead of coding btn_click, 'Page_isPostBack then InsertRecord()'
was coded to run the databae updating.
Sub Page_Load(sender As Object, e As EventArgs)
If Page.IsPostBack Then
InsertRecord()
End If
End Sub
What's wrong with this Sub InsertRecord()?
TIA,
Jeffrey
Sub InsertRecord()
Dim conClasf As OleDbConnection
Dim cmdClasf As New OleDbCommand
Dim strClasf As String
Dim strSQL As String
Dim intRowsAff As Integer
lblErrMsg.Text = ""
lblRecsAff.Text = ""
strClasf = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & _
Server.MapPath("/App_Data/classified.mdb") & ";"
conClasf = New OleDbConnection(strClasf)
conClasf.Open
Randomize
strSQL = "INSERT INTO members (" & _
"memberid, " & _
"firstname, " & _
"lastname, " & _
"[password], " & _
"confnumber, " & _
"confirmed " & _
") VALUES ('" & _
Replace(txtMemberid.Value, "'", "''") & _
"', '" & _
Replace(txtFirstname.Value, "'", "''") & _
"', '" & _
Replace(txtLastname.Value, "'", "''") & _
"', '" & _
Replace(txtPassword.Value, "'", "''") & _
"', " & _
Clng(Rnd() * 9000000) + 1000000 & _
", " & _
"False) "
cmdClasf = New OleDbCommand(strSQL, conClasf)
TryintRowsAff = cmdClasf.ExecuteNonQuery()
Catch ex As Exception
lblErrMsg.Text = ex.Message
End Try
lblRecsAff.Text = intRowsAff & " record(s) inserted"
conClasf.Close
End Sub
__________________
C. Jeffrey Wang
|