hello guys!
i have a webform that will submit the information into access database, but am getting this error when i hit the submit button:
Error Type:
Microsoft JET Database Engine (0x80004005)
Operation must use an updateable query.
/asp/project/BasicForm.asp, line 35
my form and database connection looks like this:
PHP Code:<%@ LANGUAGE="VBScript" %>
<%Option Explicit%>
<html>
<body>
<%
'This function prepares a string for being used in a SQL statement.
Function SafeForSQL(strIn)
SafeForSQL = Replace(strIn, "'", "''")
End Function
If Request.Form("cmdSubmit") <> "" Then
'The user has submitted data, save that information to the database
' This process does not check for data duplication, it does a "blind" data dump.
Dim con, strCon, strSql, strDatabasePath
'MODIFY: Set this to be the relative path to your database
strDatabasePath = "BasicForm.mdb"
'Connect to the Access database using a DSN-Less connection
Set con = Server.CreateObject("ADODB.Connection")
strCon = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & Server.MapPath(strDatabasePath)
con.Open strCon
'Generate the SQL string to store the data
strSql = "INSERT INTO FormData (FirstName, LastName, Email, Comments) " + _
"VALUES ('" + SafeForSQL(Request.Form("txtFirstName")) + "', " + _
"'" + SafeForSQL(Request.Form("txtLastName")) + "', " + _
"'" + SafeForSQL(Request.Form("txtEmail")) + "', " + _
"'" + SafeForSQL(Request.Form("txtComments")) + "')"
'Execute the SQL statement
con.Execute(strSql)
'Clean up database objects
con.Close
Set con = Nothing
%>
Display information (HTML) here that you would like displayed upon successfully adding the
information to the database.
<%
Else
'The user has not submitted the page, so display the form
%>
<form name="frmMain" action="BasicForm.asp" method="post">
<table>
<tr>
<td>First Name:</td>
<td><input type="text" name="txtFirstName" value=""></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type="text" name="txtLastName" value=""></td>
</tr>
<tr>
<td>Email:</td>
<td><input type="text" name="txtEmail" value=""></td>
</tr>
<tr>
<td colspan="2">
Comments:<br />
<textarea name="txtComments" cols="50" rows="10"></textarea>
</td>
</tr>
<tr>
<td colspan="2" align="right"><input type="submit" name="cmdSubmit" value="Submit"></td>
</tr>
</table>
</form>
<%
End If
%>
</body>
</html>


Reply With Quote
Bookmarks