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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble with insert statement

Status
Not open for further replies.

cr84net2

Programmer
Feb 8, 2005
93
US
I have a form set up that posts to itself (or the same page). I collect the values from the form and do an insert like this. I have debugged and all variables are showing up in the sql.

Code:
pInsertSql = "INSERT INTO [user] ([userlevel], [paid], [regid], [userpaid], [name], [email], [username], [upass]) VALUES (" & (ulev) & "," & (pd) & "," & (ireg) & "," & (up) & "," & (NPname) & "," & (NPemail) & "," & (NPuname) & "," & (NPupass) & "); Select Scope_Identity() id " 

Set Irs=Server.CreateObject("ADODB.Recordset")
Irs.open pInsertSql, conn 
NewID=Irs("id")

I keep getting an error like this:

Microsoft OLE DB Provider for SQL Server error '80040e14'

The name 'Midl3362985' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted.

The error relates to the (ireg) value

I have tried TextIn(ireg,50) and I get this error:
Microsoft VBScript runtime error '800a000d'

Type mismatch: 'TextIn'

When I try to put single quotes around ireg like this
","' & (ireg) & '","

I get this error:

Microsoft OLE DB Provider for SQL Server error '80040e14'

Line 1: Incorrect syntax near ','.


I am running in circles anyone have any ideas? Thanks.
 
[1] First, there are 9 fields, and only 8 values in the VALUES(). By the similitude of the naming, it seems [user] value is missing.

[2] Main thing is that as it stands, all the fields should be of some type of number. If the error starts flagging ireg, which, because of the missing [user], would assign to [paid]. If [paid] is of some varchar type, it would be 80040e14 error. In that particular case, the construction is like this.
[tt] ",[highlight]'[/highlight]" & (ireg) & "[highlight]'[/highlight]," [/tt]
rather than this, which is incorrect.
[tt]> [/tt]","' & (ireg) & '","
Similarly the construction should be equally applied to other cases where the types are not number.
 
Thanks,

I figured out the single quotes and you are right. User however is the table name, I bracket it out of habit I guess.

Thanks again!
 
Yes, I had made a hasty count. It is the table name. No problem there.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top