Forum Moderators: open

Message Too Old, No Replies

Adding Record Help!

using .asp and .mdb problems!

         

yoda84

2:57 pm on May 13, 2006 (gmt 0)

10+ Year Member



Hey Guys,
its me again, heres what i'm trying todo, i've got a form that takes the users details and i want to add them to my .mdb which is called "project.mdb". heres the code:

<%

Set conn = server.createobject("adodb.connection")
DSNtemp = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("/project/project.mdb")
conn.Open DSNtemp

mySQL = "INSERT INTO users (userName,userPass,Email,userPhone,address_1,address_2,address_3,userPost)"
mySQL = mySQL & " VALUES ('" & request.form("userName") & "','" & request.form("userPass") & "','" & request.form("userEmail") & "','" & request.form("userPhone") & "','" & request.form("add_1") & "','" & request.form("add_2") & "','" & request.form("add_3") & "','" & request.form("userPost") & "')"

DSNtemp.execute(mySQL)
Response.redirect("index.asp")
%>

but every time i try it i get:

Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: 'DSNtemp'
/project/test.asp, line 10

Anyone see what im doing wrong here?
Cheers
Yoda aka Daz

syber

3:43 pm on May 13, 2006 (gmt 0)

10+ Year Member



DSNtemp is not an object, it is a string.

Your object is conn

conn.execute(mySQL) instead of DSNtemp.execute(mySQL)

yoda84

3:48 pm on May 13, 2006 (gmt 0)

10+ Year Member



Hey!
thanks for that but now my code looks like this:

<%

Set conn = server.createobject("adodb.connection")
DSNtemp = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("/project/project.mdb")
conn.Open DSNtemp

mySQL = "INSERT INTO users (userName,userPass,Email,userPhone,address_1,address_2,address_3,userPost)"
mySQL = mySQL & " VALUES ('" & request.form("userName") & "','" & request.form("userPass") & "','" & request.form("userEmail") & "','" & request.form("userPhone") & "','" & request.form("add_1") & "','" & request.form("add_2") & "','" & request.form("add_3") & "','" & request.form("userPost") & "')"

conn.execute(mySQL)
Response.redirect("index.asp")
%>

i get this error instead:
Error Type:
Microsoft JET Database Engine (0x80004005)
Operation must use an updateable query.
/project/test.asp, line 10

any ideas?
yoda

yoda84

4:28 pm on May 13, 2006 (gmt 0)

10+ Year Member



Solved the problem!
i followed the tutorial here:

[forums.aspfree.com...]

worked fine!
thanks for the help guys!
Yoda