Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Re: Error 800040E14 when trying to INSERT to SQL Server


Message #1 by "Ken Schaefer" <ken@a...> on Tue, 16 Apr 2002 19:53:10 +1000
This is a multi-part message in MIME format.

------=_NextPart_000_0256_01C1E580.5607C950
Content-Type: text/plain;
	charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

Change your code to look like this:

<%
strSQL =3D "INSERT INTO Employee (IDNumber, EmpName, ExtensionNo, 
MentorID,
SalaryLevel, TeamID) VALUES (" & nIDNumber & ",'" & StrQuoteReplace
 (strEmpName) & "','" & StrQuoteReplace(strExtensionNo) & "'," & 
nMentorID
 & "," & nSalaryLevel & ",'" & StrQuoteReplace(strTeamID) & "')"

Response.Write(strSQL)
Response.End

 Conn.Execute(strSQL)
%>

(Add the lines marked in red). Post the output you see on the screen to 
the list.

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Eoin Hayes" <Hayes_Eoin@e...>
Subject: [asp_databases] Error 800040E14 when trying to INSERT to SQL 
Server


: OK I keep getting this error:
: Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
: [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect 
syntax
: near ','.
: /Eoinasp/page1.asp, line 139
:
: Line 139 is: Conn.Execute(strSQL)
: The page doesn't even come up at all even before hitting a Submit
: button.It is only visible when I remove the Conn.execute(strSQL) 
statement.
:
:
: Here is the code
:
: Dim nIDNumber, strEmpName, strExtensionNo, nMentorID, nSalaryLevel,
: strTeamID, strSQL, str1
:
: if Request.QueryString<>"" then
: nIDNumber =3D Request.QueryString("IDNumber")
: strEmpName =3D Request.QueryString("EmpName")
: strExtensionNo =3D Request.QueryString("ExtensionNo")
: nMentorID =3D Request.QueryString("MentorID")
: nSalaryLevel =3D Request.QueryString("SalaryLevel")
: strTeamID =3D Request.QueryString("TeamID")
: end if
:
: strSQL =3D "INSERT INTO Employee (IDNumber, EmpName, ExtensionNo, 
MentorID,
: SalaryLevel, TeamID) VALUES (" & nIDNumber & ",'" & StrQuoteReplace
: (strEmpName) & "','" & StrQuoteReplace(strExtensionNo) & "'," & 
nMentorID
: & "," & nSalaryLevel & ",'" & StrQuoteReplace(strTeamID) & "')"
:
:
:
: Conn.Execute(strSQL)
:
:
: Conn.Close
: set Conn =3D nothing
:
:
: Function StrQuoteReplace(strValue)
: str1 =3D Replace(strValue, "'", "''")
: StrQuoteReplace =3D "'" & str1 & "'"
: End Function



Message #2 by "Eoin Hayes" <Hayes_Eoin@e...> on Mon, 15 Apr 2002 19:27:46
OK I keep getting this error:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax 
near ','.
/Eoinasp/page1.asp, line 139

Line 139 is:	Conn.Execute(strSQL)
The page doesn't even come up at all even before hitting a Submit 
button.It is only visible when I remove the Conn.execute(strSQL) statement.


Here is the code

Dim nIDNumber, strEmpName, strExtensionNo, nMentorID, nSalaryLevel, 
strTeamID, strSQL, str1

if Request.QueryString<>"" then
	nIDNumber = Request.QueryString("IDNumber")
	strEmpName = Request.QueryString("EmpName")
	strExtensionNo = Request.QueryString("ExtensionNo")
	nMentorID = Request.QueryString("MentorID")
	nSalaryLevel = Request.QueryString("SalaryLevel")
	strTeamID = Request.QueryString("TeamID")
end if

strSQL = "INSERT INTO Employee (IDNumber, EmpName, ExtensionNo, MentorID, 
SalaryLevel, TeamID) VALUES (" & nIDNumber & ",'" & StrQuoteReplace
(strEmpName) & "','" & StrQuoteReplace(strExtensionNo) & "'," & nMentorID 
& "," & nSalaryLevel & ",'" & StrQuoteReplace(strTeamID) & "')"



Conn.Execute(strSQL)


Conn.Close
set Conn = nothing 	 


Function StrQuoteReplace(strValue)
str1 = Replace(strValue, "'", "''")
StrQuoteReplace = "'" & str1 & "'"
End Function 	

  Return to Index