insert into table

P

Perry

I have used the following code to insert record from my web page into the
access2000's table, but since I switch to Access 2003 these code does not
work,
can any one please help me out?!

Set oConn = Server.CreateObject("ADODB.connection")
oConn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
Server.MapPath("onlineshop.mdb"))
sql2 = "insert into M ([MID], [MKind], [Surname],
[FirstName],[Gender],,[Address1],[Address2],[Address3],[PostCode],[Country],[TelNo],[Password1])
values ('" & UCase(MID) &"','"& MKind &"','" & Surname & "', '" & FirstName &
"', '" & Gender &"','" & Email &"','" & Address1 &"','" & Address2 &"','" &
Address3 &"','" & PostCode &"','" & Country &"','" & TelNo &"','" & Password
&"')"
oConn.Execute sql2

thankyou very much for you help
 
J

JaRa

First of all check if your connectionstring is still OK.
Did you change something else to your configuration?

I also Suggest you to use some different coding since building a SQL
statement like this might break when people are using ' or " in the values.

Set oConn = Server.CreateObject("ADODB.connection")
oConn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
Server.MapPath("onlineshop.mdb"))

Set oCmd=Server.CreateObject("ADODB.Command")
oCmd.CommandText="INSERT INTO M ([MID], [MKind], [Surname],

[FirstName],[Gender],,[Address1],[Address2],[Address3],[PostCode],[Country],[TelNo],[Password1]) VALUES (?, ?, ?, ?,?,?,?,?,?,?,?,?,?)"
oCmd.ActiveConnection=oConn
oCmd.Parameters.Refresh

oCmd.Parameters(0)=UCase(MID)
oCmd.Parameters(1)=MKind
oCmd.Parameters(2)=Surname
oCmd.Parameters(3)=FirstName
oCmd.Parameters(4)=Gender
oCmd.Parameters(5)=Email
oCmd.Parameters(6)=Address1
oCmd.Parameters(7)=Address2
oCmd.Parameters(8)=Address3
oCmd.Parameters(9)=PostCode
oCmd.Parameters(10)=Country
oCmd.Parameters(11)=TelNo
oCmd.Parameters(12)=Password
oCmd.Execute
oConn.Close
Set oCmd=nothing
Set oConn=nothing

- Raoul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top