If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > MySQL syntax error

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-15-05, 15:53
xtgeminiman xtgeminiman is offline
Registered User
 
Join Date: Jan 2005
Posts: 23
MySQL syntax error

Some of my pages include paging where the variable starts with a certain letter. This worked fine in access but when I try to run it with mysql it says...

Microsoft OLE DB Provider for ODBC Drivers error '80040e37'

[MySQL][ODBC 3.51 Driver][mysqld-4.0.17-nt]You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT username, status FROM users WHERE username Like 'A%' OR

/userview.asp, line 37

My codings like this...

Code:
<%
Dim pageno,totalpages,rsuserview,pagecount,sortby,startletter, alphabet, rsmusic

startletter = Request.QueryString("startletter")

if startletter = "" then
  startletter = "A"
end if

Const adOpenForwardOnly = 0
Const adLockReadOnly = 1
Const adCmdTableDirect = &H0200
Const adUseClient = 3
%>
<%
if startletter = "nonalphabet" then
  sql = "SELECT username, status FROM users WHERE username Not Like 'a%'"
  for alphabet = 98 to 122
	sql = sql & " AND username Not Like '" & chr(alphabet) & "%'"
  next
  sql = sql & " ORDER BY username ASC"

elseif startletter = "all" then
  sql = "SELECT username, status FROM users ORDER BY username ASC"

else
  sql = "SELECT username, status FROM users WHERE username LIKE '" & startletter & "%' ORDER BY username"
end if
Set rsuserview = Server.CreateObject("ADODB.Recordset")

  rsuserview.PageSize = 100
  rsuserview.CursorLocation = adUseClient

 rsuserview.Open sql, conn, adOpenForwardOnly, adLockReadOnly, _
   adCmdTableDirect
%>
and line 37 is...

Code:
 rsuserview.Open sql, conn, adOpenForwardOnly, adLockReadOnly, _
   adCmdTableDirect
Reply With Quote
  #2 (permalink)  
Old 02-15-05, 16:14
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,246
I dont think you can use
Quote:
adCmdTableDirect
in an non native jet application, try accmdtable, or possibly accmdunknown, or failing that nothing.
HTH
Reply With Quote
  #3 (permalink)  
Old 02-15-05, 16:35
xtgeminiman xtgeminiman is offline
Registered User
 
Join Date: Jan 2005
Posts: 23
yup, i got rid of it and it worked, thanks healdem
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On