Hi,
I'm trying to use an asp page to send data from a basic HTML form to an Access database. I'm using GoDaddy hosting (which apparently many people have issues with when it comes to this) and here are my files:
form_ac.asp:
<%
' Declaring variables
Dim firstname, lastname, company, phone, email, data_source, con, SQLINSERT
' A Function to check if some field entered by user is empty
Function ChkString(string)
If string = "" Then string = " "
ChkString = Replace(string, "'", "''")
End Function
' Receiving values from Form
firstname = ChkString(Request.Form("firstname"))
lastname = ChkString(Request.Form("lastname"))
company = ChkString(Request.Form("company"))
phone = ChkString(Request.Form("phone"))
email = ChkString(Request.Form("email"))
data_source = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\hosting\trehomes\access_db\TREAgents.mdb ;"
SQLINSERT="INSERT INTO TRE1 (FirstName, LastName, Company, Phone, Email) "
SQLINSERT=SQLINSERT & "VALUES ("
SQLINSERT=SQLINSERT & "'" & firstname & "', "
SQLINSERT=SQLINSERT & "'" & lastname & "', "
SQLINSERT=SQLINSERT & "'" & company & "', "
SQLINSERT=SQLINSERT & phone & ", "
SQLINSERT=SQLINSERT & "'" & email & "') "
' Creating Connection Object and opening the database
Set con = Server.CreateObject("ADODB.Connection")
con.Mode = 3 '3 = adModeReadWrite
con.Open data_source
con.Execute SQLINSERT
' Done. Close the connection
con.Close
Set con = Nothing
%>
And the form code:
<form action="form_ac.asp" method="post">
First Name<br />
<input name="firstname" type="text" /><br />
Last Name<br />
<input name="lastname" type="text" /><br />
Company<br />
<input name="company" type="text" /><br />
Phone Number<br />
<input name="phone" type="text" /><br />
Email<br />
<input name="email" type="text" /><br />
<input type="submit" name="Submit" value="Submit">
</form>
However, I keep getting the following error:
Microsoft JET Database Engine error '80004005'
Operation must use an updateable query.
/form_ac2.asp, line 35
According to GoDaddy, once you enable access db's for the site, any databases saved in access_db folder should have the proper permissions set. I'm thinking something might be wrong with the connection? Any help is GREATLY appreciated!!