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

I got an error at the line that says "con.Execute(sql_insert)

Status
Not open for further replies.

slok

Programmer
Jul 2, 1999
108
SG
what could be the problem?

the error message is
==
Microsoft OLE DB Provider for SQL Server error '80040e14'

Line 1: Incorrect syntax near '0'.

test.asp, line 64
====


my code as follows:

====
<%@ Language=JScript %>
<%
Response.Buffer = false;
Server.ScriptTimeout = 160;
%>


<%
var flag = 0; // 1 to insert and do select
if (Request.QueryString(&quot;flag&quot;)!= &quot;&quot;) {
flag = Request.QueryString(&quot;flag&quot;);
Response.Write (&quot;Flag is &quot; + Request.QueryString(&quot;flag&quot;));
}

var dom = Server.CreateObject(&quot;MSXML2.DomDocument&quot;);
dom.async = 0;
dom.load(Server.MapPath(&quot;testexport.xml&quot;));


var parseError = dom.parseError;
if (parseError.errorCode != 0) {
var e = new Error(&quot;Error: line &quot; + parseError.line + &quot;; reason = &quot; + parseError.reason);
throw(e);
}



//Set root to the XML document's root element, COLLECTION:
var name, description, enabled;
var root = dom.documentElement;
var e, child;
e = new Enumerator(root.childNodes);   //Create Enumerator
for (;!e.atEnd();e.moveNext())
{

if (e.nodeName == &quot;name&quot;) {
child = e.item();
name = child.text;
}
else if (e.nodeName = &quot;description&quot;) {
child = e.item();
description = child.text;
}
else if (e.nodeName = &quot;enabled&quot;) {
child = e.item();
enabled = child.text;
}

if (flag == &quot;0&quot;) {
Response.Write(&quot;<p>no sql<p>&quot;);
child = e.item();
Response.Write(child.text + &quot;<p>&quot;);

}


if (flag == &quot;1&quot;){
var sql_insert;
Response.Write(&quot;<p>sql now<p>&quot;);
sql_insert = &quot;insert into cat_prdt_temp (name, description, enabled) values ('&quot; & name &&quot;', '&quot; & description & &quot;', '&quot; & enabled & &quot;')&quot;;
var con = Server.CreateObject(&quot;ADODB.Connection&quot;);
var ConnectionString = &quot;Provider=SQLOLEDB.1;Driver={SQL Server};SERVER=PORTABLE120;DATABASE=REI-Catalog;UID=sa;PWD=;&quot;
con.Open(ConnectionString);
con.Execute(sql_insert);

sql_select = &quot;select * from cat_prdt_temp&quot;;


var rs = con.Execute(sql_select);

while(!rs.EOF) {
Response.Write(rs(&quot;Name&quot;) + &quot;, &quot;);
Response.Write(rs(&quot;Description&quot;) + &quot;, &quot;);
Response.Write(rs(&quot;enabled&quot;) + &quot;<p>&quot;);
}



}

}

 
Are you sure that in one of the values ( name , description , enabled ) there is no apostrophe getting inserted. That can throw it off. Say for name you enter O'reilly, when this gets sent to sql there is an extra apostrophe and it does not understand. You might see if this could be causing the problem....
 
I just check the XML file. there is no apostrophe .

any other suggestions?
 
Do a response.write right after you create the sql_insert and let's see what is shows. That might help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top