Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: SQL Insert Error.... pls help


Message #1 by qy qy <francs_ng@y...> on Wed, 1 Aug 2001 23:12:24 -0700 (PDT)
Hi there,

Im new to ASP and I just learn ASP a few days ago. An

error occurs when I try to so SQL insert into Access

2000 database. I check with all fields inside my table

and it matches with names I assign to insert. The

error is "Microsoft OLE DB Provider for ODBC Drivers

error '80040e10'[Microsoft][ODBC Microsoft Access

Driver] Too few parameters. Expected 14"



Below are my codes:

-------------------------------------------------------



<%@Language=VBScript%>

<%Option Explicit%>

<html>

<head>

	<title>ValidateRegister Page</title>

</head>



<body>

<%



Dim oconn, strsource, ors, sqltext

Dim username, password, firstname, middlename,

lastname

Dim dateofbirth, companyname, position, income

Dim address, postalcode, homephone, handphone, email



Set oconn = Server.CreateObject("ADODB.Connection")

strsource = "DRIVER={Microsoft Access Driver

(*.mdb)};" & _

"DBQ=" & Server.MapPath("../database/danclan.mdb") &

";"

oconn.open(strsource)



Set ors = Server.CreateObject("ADODB.Recordset")



username = Request.form("username")

password = Request.form("password")

firstname = Request.form("firstname")

middlename = Request.form("middlename")

lastname = Request.form("lastname")

dateofbirth = Request.form("dateofbirth")

companyname = Request.form("companyname")

position = Request.form("position")

income = Request.form("income")

address = Request.form("address")

postalcode = Request.form("postalcode")

homephone = Request.form("homephone")

handphone = Request.form("handphone")

email = Request.form("email")



sqltext = "INSERT INTO User(UserName, FirstName,

MiddleName, LastName, HomePhone, HandPhone, Address,

PostalCode, Email, Password, CompanyName, Position,

Income, DateOfBirth) " & _

		  "VALUES(username, firstname, middlename, lastname,

homephone, handphone, address, postalcode, email,

password, companyname, position, income, dateofbirth);

"

ors.open sqltext, oconn



response.write "User Added"



%>

</body>

</html>





-------------------------------------------------------

Please kindly give me advice in GREAT DETAILS. Thank

you very much.



Your Sincerely,

franco





Message #2 by Andy@a... on Wed, 8 Aug 2001 07:49:32
Hi



Just answered another one like this.



Something I've noticed with your code - if you are writing back strings 

you need an extra set of quotes around the value variables ie 



'" & Var1 & "' if you are writing back numbers then " & qFormNumber & "



Hope this helps



Regards



Andy Green



> Hi there,

> Im new to ASP and I just learn ASP a few days ago. An

> error occurs when I try to so SQL insert into Access

> 2000 database. I check with all fields inside my table

> and it matches with names I assign to insert. The

> error is "Microsoft OLE DB Provider for ODBC Drivers

> error '80040e10'[Microsoft][ODBC Microsoft Access

> Driver] Too few parameters. Expected 14"

> 

> Below are my codes:

> -------------------------------------------------------

> 

> <%@Language=VBScript%>

> <%Option Explicit%>

> <html>

> <head>

> 	<title>ValidateRegister Page</title>

> </head>

> 

> <body>

> <%

> 

> Dim oconn, strsource, ors, sqltext

> Dim username, password, firstname, middlename,

> lastname

> Dim dateofbirth, companyname, position, income

> Dim address, postalcode, homephone, handphone, email

> 

> Set oconn = Server.CreateObject("ADODB.Connection")

> strsource = "DRIVER={Microsoft Access Driver

> (*.mdb)};" & _

> "DBQ=" & Server.MapPath("../database/danclan.mdb") &

> ";"

> oconn.open(strsource)

> 

> Set ors = Server.CreateObject("ADODB.Recordset")

> 

> username = Request.form("username")

> password = Request.form("password")

> firstname = Request.form("firstname")

> middlename = Request.form("middlename")

> lastname = Request.form("lastname")

> dateofbirth = Request.form("dateofbirth")

> companyname = Request.form("companyname")

> position = Request.form("position")

> income = Request.form("income")

> address = Request.form("address")

> postalcode = Request.form("postalcode")

> homephone = Request.form("homephone")

> handphone = Request.form("handphone")

> email = Request.form("email")

> 

> sqltext = "INSERT INTO User(UserName, FirstName,

> MiddleName, LastName, HomePhone, HandPhone, Address,

> PostalCode, Email, Password, CompanyName, Position,

> Income, DateOfBirth) " & _

> 		  "VALUES(username, firstname, middlename, lastname,

> homephone, handphone, address, postalcode, email,

> password, companyname, position, income, dateofbirth);

> "

> ors.open sqltext, oconn

> 

> response.write "User Added"

> 

> %>

> </body>

> </html>

> 

> 

> -------------------------------------------------------

> Please kindly give me advice in GREAT DETAILS. Thank

> you very much.

> 

> Your Sincerely,

> franco

> 

> 


  Return to Index