Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: what's wrong with this query string?


Message #1 by "Ping Li" <pli@l...> on Tue, 4 Dec 2001 22:16:21
My brain is exploding now. I have been trying to check user ID against 4 

different location numbers and return data if any match exists. But the 

following codes always generate an error message: Syntax error in FROM 

clause. Can anybody help debug it? I appreciate your help.



Sincerely,

Ping





<%

varID = request.form("ID")

dim rsRecord

set rsRecord = server.CreateObject("ADODB.Recordset")



rsRecord.Open "select * from Table1 where East=" & varID & "or West=" & 

varID & "or North=" & varID & "or South=" & varID , objConn, 

adOpenForwardOnly, adLockReadOnly, adCmdTable

%>  

Message #2 by "Zee Computer Consulting" <zee@t...> on Tue, 4 Dec 2001 14:53:20 -0800
Try using the constant "adCmdText" instead of "adCmdTable" in your

recordset-open statement. (Using "adCmdTable" does NOT take a select

statement as first parameter but rather just the table name.)



Question: Are your East, West, South, and North database fields numeric or

string? (Your WHERE clause is set up for numeric.)



-- Z







instead of

----- Original Message -----

From: "Ping Li" <pli@l...>

To: "Access ASP" <access_asp@p...>

Sent: Tuesday, December 04, 2001 10:16 PM

Subject: [access_asp] what's wrong with this query string?





> My brain is exploding now. I have been trying to check user ID against 4

> different location numbers and return data if any match exists. But the

> following codes always generate an error message: Syntax error in FROM

> clause. Can anybody help debug it? I appreciate your help.

>

> Sincerely,

> Ping

>

>

> <%

> varID = request.form("ID")

> dim rsRecord

> set rsRecord = server.CreateObject("ADODB.Recordset")

>

> rsRecord.Open "select * from Table1 where East=" & varID & "or West=" &

> varID & "or North=" & varID & "or South=" & varID , objConn,

> adOpenForwardOnly, adLockReadOnly, adCmdTable

> %>

>




>



Message #3 by Ping Li <pli@l...> on Tue, 4 Dec 2001 16:58:54 -0600
-----Z,

Thank you soooooo much for your suggestion. I changed adCmdTable to

adCmdText and it worked! I got the data I want. Thanks again and wish you a

great day.



Ping



-----Original Message-----

From: Zee Computer Consulting [mailto:zee@t...]

Sent: Tuesday, December 04, 2001 4:53 PM

To: Access ASP

Subject: [access_asp] Re: what's wrong with this query string?





Try using the constant "adCmdText" instead of "adCmdTable" in your

recordset-open statement. (Using "adCmdTable" does NOT take a select

statement as first parameter but rather just the table name.)



Question: Are your East, West, South, and North database fields numeric or

string? (Your WHERE clause is set up for numeric.)



-- Z







instead of

----- Original Message -----

From: "Ping Li" <pli@l...>

To: "Access ASP" <access_asp@p...>

Sent: Tuesday, December 04, 2001 10:16 PM

Subject: [access_asp] what's wrong with this query string?





> My brain is exploding now. I have been trying to check user ID against 4

> different location numbers and return data if any match exists. But the

> following codes always generate an error message: Syntax error in FROM

> clause. Can anybody help debug it? I appreciate your help.

>

> Sincerely,

> Ping

>

>

> <%

> varID = request.form("ID")

> dim rsRecord

> set rsRecord = server.CreateObject("ADODB.Recordset")

>

> rsRecord.Open "select * from Table1 where East=" & varID & "or West=" &

> varID & "or North=" & varID & "or South=" & varID , objConn,

> adOpenForwardOnly, adLockReadOnly, adCmdTable

> %>

>




>








Message #4 by Ping Li <pli@l...> on Wed, 5 Dec 2001 13:30:16 -0600
----Z,

Thank you yesterday for the great help. Then when I tried to add one

condition to retrieve only data with Paid or Dispute Payment,(please see the

following codes). error says missing operator/syntax error. In my Access

table, north, east, west, south and varID are numeric and Payment is text.

How can I combine two WHERE clauses to narrow down the return data? Thanks a

lot.



Sincerely,

Ping





<%

> varID = request.form("ID")

> dim rsRecord

> set rsRecord = server.CreateObject("ADODB.Recordset")

>

> rsRecord.Open "select * from Table1 where East=" & varID & "or West=" &

> varID & "or North=" & varID & "or South=" & varID & "and where

Payment='Paid' OR Payment='dispute'" , objConn,

> adOpenForwardOnly, adLockReadOnly, adCmdText

> %>

>



-----Original Message-----

From: Zee Computer Consulting [mailto:zee@t...]

Sent: Tuesday, December 04, 2001 4:53 PM

To: Access ASP

Subject: [access_asp] Re: what's wrong with this query string?





Try using the constant "adCmdText" instead of "adCmdTable" in your

recordset-open statement. (Using "adCmdTable" does NOT take a select

statement as first parameter but rather just the table name.)



Question: Are your East, West, South, and North database fields numeric or

string? (Your WHERE clause is set up for numeric.)



-- Z







instead of

----- Original Message -----

From: "Ping Li" <pli@l...>

To: "Access ASP" <access_asp@p...>

Sent: Tuesday, December 04, 2001 10:16 PM

Subject: [access_asp] what's wrong with this query string?





> My brain is exploding now. I have been trying to check user ID against 4

> different location numbers and return data if any match exists. But the

> following codes always generate an error message: Syntax error in FROM

> clause. Can anybody help debug it? I appreciate your help.

>

> Sincerely,

> Ping

>

>

> <%

> varID = request.form("ID")

> dim rsRecord

> set rsRecord = server.CreateObject("ADODB.Recordset")

>

> rsRecord.Open "select * from Table1 where East=" & varID & "or West=" &

> varID & "or North=" & varID & "or South=" & varID , objConn,

> adOpenForwardOnly, adLockReadOnly, adCmdTable

> %>

>




>








Message #5 by "Zee Computer Consulting" <zee@t...> on Thu, 6 Dec 2001 18:30:25 -0800
Simply put parentheses around each sub-clause and join them with the AND

keyword (and make sure there are spaces before and after WHERE, OR, AND, and

other keywords):



SqlString = "SELECT * FROM Table1 " _

& " WHERE ( East=" & varID _

& " OR West=" & varID _

& " OR North=" & varID _

& " OR South=" & varID  ) _

& " AND ( Payment='Paid' _

& " OR Payment='dispute' )"



Z







----- Original Message -----

From: "Ping Li" <pli@l...>

To: "Access ASP" <access_asp@p...>

Sent: Wednesday, December 05, 2001 11:30 AM

Subject: [access_asp] Re: what's wrong with this query string?





> ----Z,

> Thank you yesterday for the great help. Then when I tried to add one

> condition to retrieve only data with Paid or Dispute Payment,(please see

the

> following codes). error says missing operator/syntax error. In my Access

> table, north, east, west, south and varID are numeric and Payment is text.

> How can I combine two WHERE clauses to narrow down the return data? Thanks

a

> lot.

>

> Sincerely,

> Ping

>

>

> <%

> > varID = request.form("ID")

> > dim rsRecord

> > set rsRecord = server.CreateObject("ADODB.Recordset")

> >

> > rsRecord.Open "select * from Table1 where East=" & varID & "or West=" &

> > varID & "or North=" & varID & "or South=" & varID & "and where

> Payment='Paid' OR Payment='dispute'" , objConn,

> > adOpenForwardOnly, adLockReadOnly, adCmdText

> > %>

> >

>

> -----Original Message-----

> From: Zee Computer Consulting [mailto:zee@t...]

> Sent: Tuesday, December 04, 2001 4:53 PM

> To: Access ASP

> Subject: [access_asp] Re: what's wrong with this query string?

>

>

> Try using the constant "adCmdText" instead of "adCmdTable" in your

> recordset-open statement. (Using "adCmdTable" does NOT take a select

> statement as first parameter but rather just the table name.)

>

> Question: Are your East, West, South, and North database fields numeric or

> string? (Your WHERE clause is set up for numeric.)

>

> -- Z

>

>

>

> instead of

> ----- Original Message -----

> From: "Ping Li" <pli@l...>

> To: "Access ASP" <access_asp@p...>

> Sent: Tuesday, December 04, 2001 10:16 PM

> Subject: [access_asp] what's wrong with this query string?

>

>

> > My brain is exploding now. I have been trying to check user ID against 4

> > different location numbers and return data if any match exists. But the

> > following codes always generate an error message: Syntax error in FROM

> > clause. Can anybody help debug it? I appreciate your help.

> >

> > Sincerely,

> > Ping

> >

> >

> > <%

> > varID = request.form("ID")

> > dim rsRecord

> > set rsRecord = server.CreateObject("ADODB.Recordset")

> >

> > rsRecord.Open "select * from Table1 where East=" & varID & "or West=" &

> > varID & "or North=" & varID & "or South=" & varID , objConn,

> > adOpenForwardOnly, adLockReadOnly, adCmdTable

> > %>

> >




$subst('Email.Unsub')

> >

>

>




>




$subst('Email.Unsub').



Message #6 by Ping Li <pli@l...> on Fri, 7 Dec 2001 11:31:02 -0600
It works. Thanks for your help, Zee

Have a good weekend.

Ping



-----Original Message-----

From: Zee Computer Consulting [mailto:zee@t...]

Sent: Thursday, December 06, 2001 8:30 PM

To: Access ASP

Subject: [access_asp] Re: what's wrong with this query string?





Simply put parentheses around each sub-clause and join them with the AND

keyword (and make sure there are spaces before and after WHERE, OR, AND, and

other keywords):



SqlString = "SELECT * FROM Table1 " _

& " WHERE ( East=" & varID _

& " OR West=" & varID _

& " OR North=" & varID _

& " OR South=" & varID  ) _

& " AND ( Payment='Paid' _

& " OR Payment='dispute' )"



Z







----- Original Message -----

From: "Ping Li" <pli@l...>

To: "Access ASP" <access_asp@p...>

Sent: Wednesday, December 05, 2001 11:30 AM

Subject: [access_asp] Re: what's wrong with this query string?





> ----Z,

> Thank you yesterday for the great help. Then when I tried to add one

> condition to retrieve only data with Paid or Dispute Payment,(please see

the

> following codes). error says missing operator/syntax error. In my Access

> table, north, east, west, south and varID are numeric and Payment is text.

> How can I combine two WHERE clauses to narrow down the return data? Thanks

a

> lot.

>

> Sincerely,

> Ping

>

>

> <%

> > varID = request.form("ID")

> > dim rsRecord

> > set rsRecord = server.CreateObject("ADODB.Recordset")

> >

> > rsRecord.Open "select * from Table1 where East=" & varID & "or West=" &

> > varID & "or North=" & varID & "or South=" & varID & "and where

> Payment='Paid' OR Payment='dispute'" , objConn,

> > adOpenForwardOnly, adLockReadOnly, adCmdText

> > %>

> >

>

> -----Original Message-----

> From: Zee Computer Consulting [mailto:zee@t...]

> Sent: Tuesday, December 04, 2001 4:53 PM

> To: Access ASP

> Subject: [access_asp] Re: what's wrong with this query string?

>

>

> Try using the constant "adCmdText" instead of "adCmdTable" in your

> recordset-open statement. (Using "adCmdTable" does NOT take a select

> statement as first parameter but rather just the table name.)

>

> Question: Are your East, West, South, and North database fields numeric or

> string? (Your WHERE clause is set up for numeric.)

>

> -- Z

>

>

>

> instead of

> ----- Original Message -----

> From: "Ping Li" <pli@l...>

> To: "Access ASP" <access_asp@p...>

> Sent: Tuesday, December 04, 2001 10:16 PM

> Subject: [access_asp] what's wrong with this query string?

>

>

> > My brain is exploding now. I have been trying to check user ID against 4

> > different location numbers and return data if any match exists. But the

> > following codes always generate an error message: Syntax error in FROM

> > clause. Can anybody help debug it? I appreciate your help.

> >

> > Sincerely,

> > Ping

> >

> >

> > <%

> > varID = request.form("ID")

> > dim rsRecord

> > set rsRecord = server.CreateObject("ADODB.Recordset")

> >

> > rsRecord.Open "select * from Table1 where East=" & varID & "or West=" &

> > varID & "or North=" & varID & "or South=" & varID , objConn,

> > adOpenForwardOnly, adLockReadOnly, adCmdTable

> > %>

> >




$subst('Email.Unsub')

> >

>

>




>




$subst('Email.Unsub').









  Return to Index