Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Access To SQL
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Access To SQL

 Post Reply Post Reply
Author
zaboss View Drop Down
Senior Member
Senior Member


Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
Post Options Post Options   Thanks (0) Thanks(0)   Quote zaboss Quote  Post ReplyReply Direct Link To This Post Topic: Access To SQL
    Posted: 26 June 2003 at 7:43am

I am in the middle of migrating an app from Access to SQL Server and I'm in a desperate need of some relevant articles on SQL queries differences between those. 

For instance:

 <% msql = "SELECT * FROM InnerMessages WHERE InnerMessages.DateRead is Null AND InnerMessages.To='"& Session("UserName") &"'"
Set RS1 = Server.CreateObject("ADODB.Recordset")
RS1.Open msql, MyConn, 1,3 %> works with acces,but returns the error:

Error Type:
Microsoft OLE DB Provider for SQL Server (0x80040E14)
Incorrect syntax near the keyword 'To'.

on SQL Server. And there are several others...

Cristian Banu
Soft 4 web
Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 26 June 2003 at 8:45am
Sounds less like a SQL Server problem and more like there being nothing stored in the Session variable. If you print out the SQL statement I'm sure it looks like this:
SELECT * FROM InnerMessages WHERE InnerMessages.DateRead is Null AND InnerMessages.To=''

which SQL will not accept. To circumvent that just check the length of the session variable before placing it in the SQL statement.
Back to Top
zaboss View Drop Down
Senior Member
Senior Member


Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
Post Options Post Options   Thanks (0) Thanks(0)   Quote zaboss Quote  Post ReplyReply Direct Link To This Post Posted: 26 June 2003 at 10:40am
No, it's not that problem. The code works perfectly with access as it is.
Cristian Banu
Soft 4 web
Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 26 June 2003 at 11:12am
I may work with Access but SQL server will not search for '', it's either null or a value. Try inserting a value instead of the session variable and I assure you that SQL Server will not return the error.
Back to Top
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post Posted: 26 June 2003 at 11:13am

you will need to change the field called To to something else, IE messageTo, as To is a reserved keyword.

Back to Top
zaboss View Drop Down
Senior Member
Senior Member


Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
Post Options Post Options   Thanks (0) Thanks(0)   Quote zaboss Quote  Post ReplyReply Direct Link To This Post Posted: 26 June 2003 at 12:17pm

Nope, Gullanian, it is not that as I have a similar error somewhere else. And also, To is a reserved word for Access too, but on both you CAN use tablename.To... The problem is with that single quotes I'm sure as the problem appears in the sql queries that use them.

And ljamal, I know for sure that it triggers the session variable as i have on another page an Response.Write(Session("UserName")) whici is fine.

Cristian Banu
Soft 4 web
Back to Top
zaboss View Drop Down
Senior Member
Senior Member


Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
Post Options Post Options   Thanks (0) Thanks(0)   Quote zaboss Quote  Post ReplyReply Direct Link To This Post Posted: 26 June 2003 at 12:40pm
Damn, Gullanian, you were right. Those field names should be in []!!!! Thanks man!
Cristian Banu
Soft 4 web
Back to Top
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post Posted: 26 June 2003 at 3:31pm
No problem hehe
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.