Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

odbc access connection insert problem 1

Status
Not open for further replies.

hemal666

Programmer
Dec 10, 2001
25
GB
hi people
ive written a siomple script to inserta record into an Access data base, when i try to execute the code i get the following error, which i belive means that a colum in the table is not peresent (which it is)
46|80040e10|[Microsoft][ODBC_Microsoft_Access_Driver]_Too_few_parameters._Expected_1. 200 0 1419 962 70

heres my code
Code:
<body>
<%
'Declare Variables
Dim CompanyName , ContactTitle , ContactFirstName
dim ContactLastName , BillingAddress1 , BillingAddress2
dim Town , City , PostalCode
dim PhoneNumber , Extension , FaxNumber
dim EmailAddress , Notes , passdone
'obtain Values from the form
CompanyName = Request.Form("CompanyName")
ContactTitle = Request.Form("ContactTitle")
ContactFirstName = Request.Form("ContactFirstName")
ContactLastName = Request.Form("ContactLastName")
BillingAddress1 = Request.Form("BillingAddress1")
BillingAddress2 = Request.Form("BillingAddress2")
Town = Request.Form("Town")
City = Request.Form("City")
PostalCode = Request.Form("PostalCode")
PhoneNumber = Request.Form("PhoneNumber")
Extension = Request.Form("Extension")
FaxNumber = Request.Form("FaxNumber")
EmailAddress = Request.Form("EmailAddress")
Notes = Request.Form("Notes")
passdone = Request.Form("passdone")
'dbconnection
Dim objConn , objRS , strDSN
Dim strSQL , adOpenStatic , adLockReadOnly
Set objConn = Server.CreateObject("ADODB.Connection")
Set objRS  = Server.CreateObject("ADODB.Recordset")
' Set the ADO Constants if you are not including 
' the adovbs.inc file
'Const adOpenStatic  = 3
'Const adLockReadOnly = 1

strDSN = "DSN=inv"
objConn.Open strDSN
strSQL = "INSERT INTO tblpassenger	([CompanyName],[ContactTitle],[ContactFirstName],[ContactLastName],[BillingAddress1],[BillingAddress2],[Town],[City],[PostalCode],[PhoneNumber],[Extension],[FaxNumber],[EmailAddress],[Notes])VALUES("&CompanyName&",'"&ContactTitle&"','"&ContactFirstName&"','"&ContactLastName&"','"&BillingAddress1&"','"&BillingAddress2&"','"&Town&"','"&City&"','"&PostalCode&"','"&PhoneNumber&"','"&Extension&"','"&FaxNumber&"','"&EmailAddress&"','"&Notes&"')"
objRS.Open strSQL, objConn
' Close Recordset and connection
objRS.Close
Set objRS = Nothing
objConn.Close
Set objConn = Nothing

plaese help
thanks hemal
 
erm.. all field names are spelt correctly, all data types are correct and none of the values are blank..............im still stuck
 
CompanyName is not enclosed in single quotes.

VALUES("&CompanyName&",'"&ContactTitle&....


If that fails, you might have a problem because the string is longer than 2 lines. Try something like:

strSQL = "blah blah blah"
strSQL = strSQL & "more blah blah blah"

 
Also,

Just out of curiosity.. are you running a check to make sure that EVERY form field was filled out? If not that can get you into run-time errors if ppl leave out fields.

lovejaeeun
 
im just too dumb to notice little things like that sometimes.... the quotes were the problem Thanks m8
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top