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(strin g)
If string = "" Then string = " "
ChkString = Replace(string, "'", "''")
End Function
' Receiving values from Form
firstname = ChkString(Reque st.Form("firstn ame"))
lastname = ChkString(Reque st.Form("lastna me"))
company = ChkString(Reque st.Form("compan y"))
phone = ChkString(Reque st.Form("phone" ))
email = ChkString(Reque st.Form("email" ))
data_source = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=d:\hosti ng\trehomes\acc ess_db\TREAgent s.mdb;"
SQLINSERT="INSE RT INTO TRE1 (FirstName, LastName, Company, Phone, Email) "
SQLINSERT=SQLIN SERT & "VALUES ("
SQLINSERT=SQLIN SERT & "'" & firstname & "', "
SQLINSERT=SQLIN SERT & "'" & lastname & "', "
SQLINSERT=SQLIN SERT & "'" & company & "', "
SQLINSERT=SQLIN SERT & phone & ", "
SQLINSERT=SQLIN SERT & "'" & email & "') "
' Creating Connection Object and opening the database
Set con = Server.CreateOb ject("ADODB.Con nection")
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!!
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(strin g)
If string = "" Then string = " "
ChkString = Replace(string, "'", "''")
End Function
' Receiving values from Form
firstname = ChkString(Reque st.Form("firstn ame"))
lastname = ChkString(Reque st.Form("lastna me"))
company = ChkString(Reque st.Form("compan y"))
phone = ChkString(Reque st.Form("phone" ))
email = ChkString(Reque st.Form("email" ))
data_source = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=d:\hosti ng\trehomes\acc ess_db\TREAgent s.mdb;"
SQLINSERT="INSE RT INTO TRE1 (FirstName, LastName, Company, Phone, Email) "
SQLINSERT=SQLIN SERT & "VALUES ("
SQLINSERT=SQLIN SERT & "'" & firstname & "', "
SQLINSERT=SQLIN SERT & "'" & lastname & "', "
SQLINSERT=SQLIN SERT & "'" & company & "', "
SQLINSERT=SQLIN SERT & phone & ", "
SQLINSERT=SQLIN SERT & "'" & email & "') "
' Creating Connection Object and opening the database
Set con = Server.CreateOb ject("ADODB.Con nection")
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!!
Comment