|
 |
asp_databases thread: syntax error
Message #1 by Wendy_wang@m... on Thu, 8 Jun 2000 14:18:46
|
|
Hi, ASP team:
I am working on the following code:
<%
strServerName = Request.Form("ServerName")
SQL = "SELECT * FROM SRV_System_Info WHERE ServerName ="'& strServerName
&'""
Set objConnection = Server.CreateObject("ADODB.Connection")
objConnection.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User
ID=MyUserID;Password=Mypassword;Initial Catalog=MyDatabase;Data
Source=MyServer"
Set objCommand = Server.CreateObject("ADODB.Command")
Set RS = Server.CreateObject("ADODB.Recordset")
objCommand.CommandText = SQL
objCommand.CommandType = adCmdText
Set objCommand.ActiveConnection = objConnection
RS.Open objCommand,,adOpenForwardOnly,adLockReadOnly
%>
And got the follwoing error message:
"Microsoft OLE DB Provider for SQL Server error '80040e14'
Line 1: Incorrect syntax near '='.
/es3/Mmodify2.asp, line 28 (Which is 'Set objCommand.ActiveConnection =
objConnection')".
Does anybody has anyidea about hoow to fix this error?
Thanks in advance.
Wendy
Message #2 by "Mukul Jain" <jainmukul@h...> on Thu, 08 Jun 2000 22:25:34 IST
|
|
why you are doing this in this way. Try this and I am sure it will work
<%
strServerName = Request.Form("ServerName")
SQL = "SELECT * FROM SRV_System_Info WHERE ServerName ="'& strServerName
&'""
Set objConnection = Server.CreateObject("ADODB.Connection")
objConnection.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User
ID=MyUserID;Password=Mypassword;Initial Catalog=MyDatabase;Data
Source=MyServer"
Set RS = Server.CreateObject("ADODB.Recordset")
RS.Open SQL,objconnection,adOpenForwardOnly,adLockReadOnly
%>
Try the same, I am sure it should work
Mukul
From: Wendy_wang@m...
Reply-To: "ASP Databases" <asp_databases@p...>
To: "ASP Databases" <asp_databases@p...>
Subject: [asp_databases] syntax error
Date: Thu, 8 Jun 2000 14:18:46
Hi, ASP team:
I am working on the following code:
<%
strServerName = Request.Form("ServerName")
SQL = "SELECT * FROM SRV_System_Info WHERE ServerName ="'& strServerName
&'""
Set objConnection = Server.CreateObject("ADODB.Connection")
objConnection.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User
ID=MyUserID;Password=Mypassword;Initial Catalog=MyDatabase;Data
Source=MyServer"
Set objCommand = Server.CreateObject("ADODB.Command")
Set RS = Server.CreateObject("ADODB.Recordset")
objCommand.CommandText = SQL
objCommand.CommandType = adCmdText
Set objCommand.ActiveConnection = objConnection
RS.Open objCommand,,adOpenForwardOnly,adLockReadOnly
%>
And got the follwoing error message:
"Microsoft OLE DB Provider for SQL Server error '80040e14'
Line 1: Incorrect syntax near '='.
/es3/Mmodify2.asp, line 28 (Which is 'Set objCommand.ActiveConnection
objConnection')".
Does anybody has anyidea about hoow to fix this error?
Thanks in advance.
Wendy
Message #3 by "Mukul Jain" <jainmukul@h...> on Thu, 08 Jun 2000 22:43:18 IST
|
|
oops there was an error check this
<%
strServerName = Request.Form("ServerName")
SQL = "SELECT * FROM SRV_System_Info WHERE ServerName =" & "'" &
strServerName & "'"
Set objConnection = Server.CreateObject("ADODB.Connection")
objConnection.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User
ID=MyUserID;Password=Mypassword;Initial Catalog=MyDatabase;Data
Source=MyServer"
Set RS = Server.CreateObject("ADODB.Recordset")
RS.Open SQL,objconnection,adOpenForwardOnly,adLockReadOnly
%>
Mukul
Try the same, I am sure it should work
Mukul
From: Wendy_wang
Reply-To: "ASP Databases" <asp_databases@p...>
To: "ASP Databases" <asp_databases@p...>
Subject: [asp_databases] syntax error
Date: Thu, 8 Jun 2000 14:18:46
Hi, ASP team:
I am working on the following code:
<%
strServerName = Request.Form("ServerName")
SQL = "SELECT * FROM SRV_System_Info WHERE ServerName ="'& strServerName
&'""
Set objConnection = Server.CreateObject("ADODB.Connection")
objConnection.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User
ID=MyUserID;Password=Mypassword;Initial Catalog=MyDatabase;Data
Source=MyServer"
Set objCommand = Server.CreateObject("ADODB.Command")
Set RS = Server.CreateObject("ADODB.Recordset")
objCommand.CommandText = SQL
objCommand.CommandType = adCmdText
Set objCommand.ActiveConnection = objConnection
RS.Open objCommand,,adOpenForwardOnly,adLockReadOnly
%>
And got the follwoing error message:
"Microsoft OLE DB Provider for SQL Server error '80040e14'
Line 1: Incorrect syntax near '='.
/es3/Mmodify2.asp, line 28 (Which is 'Set objCommand.ActiveConnection
objConnection')".
Does anybody has anyidea about hoow to fix this error?
Thanks in advance.
Wendy
Message #4 by "Wang, Wendy" <wendy_wang@m...> on Thu, 08 Jun 2000 15:30:24 -0400
|
|
Mukul,
Thanks for your advice. But I still Got the follwoing error :
Microsoft VBScript compilation error '800a03ea'
Syntax error
/es3/Update/UpdateSysInfo.asp, line 20
SQL = "SELECT * FROM SRV_System_Info WHERE ServerName =" & "'" &
Any idea?
Wendy
-----Original Message-----
From: Mukul Jain
Sent: Thursday, June 08, 2000 1:13 PM
To: ASP Databases
Subject: [asp_databases] Re: syntax error
oops there was an error check this
<%
strServerName = Request.Form("ServerName")
SQL = "SELECT * FROM SRV_System_Info WHERE ServerName =" & "'" &
strServerName & "'"
Set objConnection = Server.CreateObject("ADODB.Connection")
objConnection.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User
ID=MyUserID;Password=Mypassword;Initial Catalog=MyDatabase;Data
Source=MyServer"
Set RS = Server.CreateObject("ADODB.Recordset")
RS.Open SQL,objconnection,adOpenForwardOnly,adLockReadOnly
%>
Mukul
Try the same, I am sure it should work
Mukul
From: Wendy_wang
Reply-To: "ASP Databases" <asp_databases@p...>
To: "ASP Databases" <asp_databases@p...>
Subject: [asp_databases] syntax error
Date: Thu, 8 Jun 2000 14:18:46
Hi, ASP team:
I am working on the following code:
<%
strServerName = Request.Form("ServerName")
SQL = "SELECT * FROM SRV_System_Info WHERE ServerName ="'& strServerName
&'""
Set objConnection = Server.CreateObject("ADODB.Connection")
objConnection.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User
ID=MyUserID;Password=Mypassword;Initial Catalog=MyDatabase;Data
Source=MyServer"
Set objCommand = Server.CreateObject("ADODB.Command")
Set RS = Server.CreateObject("ADODB.Recordset")
objCommand.CommandText = SQL
objCommand.CommandType = adCmdText
Set objCommand.ActiveConnection = objConnection
RS.Open objCommand,,adOpenForwardOnly,adLockReadOnly
%>
And got the follwoing error message:
"Microsoft OLE DB Provider for SQL Server error '80040e14'
Line 1: Incorrect syntax near '='.
/es3/Mmodify2.asp, line 28 (Which is 'Set objCommand.ActiveConnection
objConnection')".
Does anybody has anyidea about hoow to fix this error?
Thanks in advance.
Wendy
Message #5 by "Ken Schaefer" <ken.s@a...> on Fri, 9 Jun 2000 18:18:56 +1000
|
|
Wendy - look at the line you pasted - does it look like any SQL string that
you recognise? It sure doesn't to me.
When you look at Mukul's email, you should have noticed that that line
wrapped around onto the next line because it was too long to fit onto a
single line. You need to "unwrap" it so that it's all back on one line
again.
strSQL = "SELECT * "
strSQL = strSQL & "FROM SRV_System_Info "
strSQL = strSQL & "WHERE ServerName = '" & strServerName & "'"
will get you want you want (you don't need to put the above three lines onto
one line because I'm concatenating the statement.
Also, don't use SELECT * - replace the * with all the field names that you
want to use.
Cheers
Ken
----- Original Message -----
From: "Wang, Wendy"
To: "ASP Databases" <asp_databases@p...>
Sent: Friday, June 09, 2000 5:30 AM
Subject: [asp_databases] Re: syntax error
> Mukul,
>
> Thanks for your advice. But I still Got the follwoing error :
>
> Microsoft VBScript compilation error '800a03ea'
>
> Syntax error
>
> /es3/Update/UpdateSysInfo.asp, line 20
>
> SQL = "SELECT * FROM SRV_System_Info WHERE ServerName =" & "'" &
>
> Any idea?
>
> Wendy
>
>
> -----Original Message-----
> From: Mukul Jain
> Sent: Thursday, June 08, 2000 1:13 PM
> To: ASP Databases
> Subject: [asp_databases] Re: syntax error
>
> oops there was an error check this
>
> <%
> strServerName = Request.Form("ServerName")
> SQL = "SELECT * FROM SRV_System_Info WHERE ServerName =" & "'" &
> strServerName & "'"
> Set objConnection = Server.CreateObject("ADODB.Connection")
> objConnection.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User
> ID=MyUserID;Password=Mypassword;Initial Catalog=MyDatabase;Data
> Source=MyServer"
> Set RS = Server.CreateObject("ADODB.Recordset")
> RS.Open SQL,objconnection,adOpenForwardOnly,adLockReadOnly
> %>
>
>
> Mukul
Message #6 by "Mukul Jain" <jainmukul@h...> on Fri, 09 Jun 2000 14:18:00 IST
|
|
Wendy,
Put that entire SQL in one line..
Have u put that into mutiple line as appeared in the email,
Make sure that u have the entire SQL declaration in one single line !!
Let me know if still probs..
Mukul
|
|
 |