Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Trouble with Inseting new records


Message #1 by yfridmn@n... on Thu, 24 Aug 2000 12:17:1
When I attempt to add new records in a database based on form values, I get 

the following error message.



 Microsoft OLE DB Provider for ODBC Drivers error '80040e10' 

[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.



When I hardcode the values, a new record is created without problems.

Any suggestions?

Here's my code:

<% 

Dim txtmyfname, txtmylname

txtmyfname=Request.form("myfirstname")

txtmylname=Request.form("mylastname")



Set objConn=Server.CreateObject("adodb.connection")

objConn.open "dsn=newdb;"



strValue1= "'" & txtmyfname & "'"

strValue2= "'" & txtmylname & "'"



strSQL= "INSERT INTO tblProfile (fname, lname) Values (strValue1, 

strValue2)"

objConn.execute(strSQL)	



objConn.close

Set objConn=Nothing

%> 

Message #2 by Imar Spaanjaars <Imar@S...> on Thu, 24 Aug 2000 14:12:18 +0200
Do a response.write of your SQL statement, to help you debugging.

Maybe one of your variables is empty, but you're not gonna find out which 

one, if you don't write out your statement just before executing it.



If you had done that, you would have seen that the strSQL is build incorrectly.



Try this:

strSQL= "INSERT INTO tblProfile (fname, lname) Values (" & strValue1 & 

",  " & strValue2 & ")"





Imar





At 12:17 PM 8/24/2000 +0000, you wrote:

>When I attempt to add new records in a database based on form values, I get

>the following error message.

>

>  Microsoft OLE DB Provider for ODBC Drivers error '80040e10'

>[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.

>

>When I hardcode the values, a new record is created without problems.

>Any suggestions?

>Here's my code:

><%

>Dim txtmyfname, txtmylname

>txtmyfname=Request.form("myfirstname")

>txtmylname=Request.form("mylastname")

>

>Set objConn=Server.CreateObject("adodb.connection")

>objConn.open "dsn=newdb;"

>

>strValue1= "'" & txtmyfname & "'"

>strValue2= "'" & txtmylname & "'"

>

>strSQL= "INSERT INTO tblProfile (fname, lname) Values (strValue1,

>strValue2)"

>objConn.execute(strSQL)

>

>objConn.close

>Set objConn=Nothing

>%>

>

>---

>You are currently subscribed to asp_databases







  Return to Index