473,804 Members | 2,271 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Ms Access to MySQL conversion on asp shows this error

20 New Member
I have an asp website, and i was using an MS Acess database, and i had to move to MySQL. I'm using a database converter, and some of the data shows, and other pulls up errors which im trying to resolve.



At the bottom is the full code of this page, but here is the part that seems to be causing the problem.


Expand|Select|Wrap|Line Numbers
  1. SELECT TOP 1 ID FROM nm_tbl_comment WHERE fldNEWS_ID = 3324 AND ID > 585 ORDER BY ID ASC 
When i ran the above code in the MySQL query analayser this is the result:
error 1064

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 '1 ID, `ID` FROM nm_tbl_comment WHERE fldNEWS_ID = 3324 AND ID > 585 ORDER BY ID' at line 1

So does anyone know what i need to do? how can i solve this problem? I'm prepared to change the method of importing data, but don't know how to do it. I used a database converter, as i thought it would be easy, but even the database converter cant convert some of code it seems

I am including all the relevant code in this page below, as it may be clearer to anyone who understands , what the problem may be.



Expand|Select|Wrap|Line Numbers
  1. <!--#include file="../config.asp"-->
  2.  
  3.    <% Dim ID, RS, SQL, NAME, EMAIL, COMMENT, sDATE, IO, M_ID, SUBJECT, CITY, COUNTRY, ALLOW_E, AID, NEXT_ID, BACK_ID
  4.  
  5.  ID = Trim(Request.QueryString("ID"))
  6.  AID = Trim(Request.QueryString("AID"))
  7.  IF IS_VALID_ID(ID) = False OR IS_VALID_ID(AID) = False THEN Response.END
  8.  IF Trim(Session("PMMS_IN")) = "True" THEN blLOGGED_IN = True 
  9.  
  10.  SQL = "SELECT fldNAME, fldEMAIL, fldCOMMENT, fldDATE, fldIP, fldM_ID, fldSUBJECT, fldCITY, fldCOUNTRY, fldALLOW FROM nm_tbl_comment WHERE ID = " & ID
  11.  Call OPEN_DB()
  12.  
  13.  ' Comment details
  14.  
  15.  Set RS = Server.CreateObject("ADODB.Recordset")
  16.  RS.LockType   = 1
  17.  RS.CursorType = 0
  18.  RS.Open SQL, MyConn 
  19.    IF NOT RS.EOF THEN
  20.     NAME = trim(RS("fldNAME"))
  21.    EMAIL = trim(RS("fldEMAIL"))
  22.    COMMENT = trim(RS("fldCOMMENT")) & ""
  23.    sDATE = trim(RS("fldDATE"))
  24.    IP = trim(RS("fldIP"))
  25.    M_ID = trim(RS("fldM_ID"))
  26.    SUBJECT = trim(RS("fldSUBJECT"))
  27.    CITY = trim(RS("fldCITY"))
  28.    COUNTRY = trim(RS("fldCOUNTRY"))
  29.    ALLOW_E = trim(RS("fldALLOW"))   
  30.    END IF
  31.  RS.Close 
  32.  Set RS = Nothing
  33.  
  34.  ' Next Link
  35.  
  36.  SQL = "SELECT TOP 1 ID FROM nm_tbl_comment WHERE fldNEWS_ID = " & AID & " AND ID > " & ID & " ORDER BY ID ASC"
  37.  Set RS = Server.CreateObject("ADODB.Recordset")
  38.  RS.Open SQL, MyConn 
  39.    IF NOT RS.EOF THEN
  40.     NEXT_ID = trim(RS("ID"))
  41.    END IF
  42.  RS.Close 
  43.  Set RS = Nothing
  44.  
  45.  ' Back Link
  46.  
  47.  SQL = "SELECT TOP 1 ID FROM nm_tbl_comment WHERE fldNEWS_ID = " & AID & " AND ID < " & ID & " ORDER BY ID DESC"
  48.  Set RS = Server.CreateObject("ADODB.Recordset")
  49.  RS.Open SQL, MyConn 
  50.    IF NOT RS.EOF THEN
  51.     BACK_ID = trim(RS("ID"))
  52.    END IF
  53.  RS.Close 
  54.  Set RS = Nothing 
  55.  
  56.  MyConn.Close
  57.  Set MyConn = Nothing
  58.  
  59.  
  60.  
  61. %>
any help appreciated, thanks in advance
Oct 19 '08 #1
4 2297
Atli
5,058 Recognized Expert Expert
Hi.

It's the "TOP 1" part that is causing the problem. The TOP clause doesn't exist in MySQL. Use LIMIT instead.

For example, to get the first row in a table:
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM aTable LIMIT 1
The advantage of the LIMIT clause over TOP is that you can also specify an offset, like:
Expand|Select|Wrap|Line Numbers
  1. SELECT * aTable LIMIT 10, 1
Which would read one row, starting at row number 10.
Oct 19 '08 #2
janetopps
20 New Member
Thank you for your reply, Atli

I tried changing the code in line 36 and 47 to:

Expand|Select|Wrap|Line Numbers
  1. SQL = "SELECT * FROM aTable LIMIT 1 ID FROM nm_tbl_comment WHERE fldNEWS_ID = " & AID & " AND ID > " & ID & " ORDER BY ID ASC"
however it didn't solve it,

This page is opened in a javascript pop up window as it is an article comment. It's actual calling page is another page (the news article). But i don't think that is of relevence or is it? i dont think i change to change the code in the article page do i?


On the news article page, this is the code that opens up the page whose code i posted above. It's opened up in a small javascript window. In the error message it says the error is actually in the comment page itself. But just in case, here is the code for the article page that opens the comment page:

Expand|Select|Wrap|Line Numbers
  1.   <%
  2.  
  3. SQL = "SELECT ID, fldNAME, fldCOMMENT, fldDATE, fldSUBJECT, fldM_ID, fldCITY, fldCOUNTRY, fldALLOW, fldEMAIL FROM nm_tbl_comment WHERE fldNEWS_ID = " & NID & " ORDER BY ID ASC"
  4. Set RS = Server.CreateObject("ADODB.Recordset")
  5. RS.LockType   = 1
  6. RS.CursorType = 0
  7. RS.Open SQL, MyConn    
  8. WHILE NOT RS.EOF 
  9. CCOUNT    = CCOUNT + 1
  10. C_ID      = trim(RS("ID"))
  11. C_NAME    = trim(RS("fldNAME"))
  12. C_COMMENT = trim(RS("fldCOMMENT"))
  13. C_SUBJECT = trim(RS("fldSUBJECT"))
  14. C_M_ID    = trim(RS("fldM_ID"))
  15. C_DATE    = trim(RS("fldDATE"))
  16. C_CITY    = trim(RS("fldCITY"))
  17. C_COUNTRY = trim(RS("fldCOUNTRY"))
  18. C_ALLOW_E = trim(RS("fldALLOW"))    
  19. C_EMAIL = trim(RS("fldEMAIL"))    
  20. %>
Oct 19 '08 #3
Atli
5,058 Recognized Expert Expert
I tried changing the code in line 36 and 47 to:

Expand|Select|Wrap|Line Numbers
  1. SQL = "SELECT * FROM aTable LIMIT 1 ID FROM nm_tbl_comment WHERE fldNEWS_ID = " & AID & " AND ID > " & ID & " ORDER BY ID ASC"
however it didn't solve it,
Of course that didn't solve it. You have two FROM clauses in there, once of which refers to a table that I made up for my example!

You need to add the LIMIT clause to your old query, while removing the TOP clause.
The LIMIT clause needs to be the last thing in your query, like it was in my example query.

See the MySQL manual page on the SELECT statement to see exactly how it should be used.
Oct 19 '08 #4
janetopps
20 New Member
Of course that didn't solve it. You have two FROM clauses in there, once of which refers to a table that I made up for my example!

You need to add the LIMIT clause to your old query, while removing the TOP clause.
The LIMIT clause needs to be the last thing in your query, like it was in my example query.

See the MySQL manual page on the SELECT statement to see exactly how it should be used.

Atli, thanks, that worked. Much appreciated.

I wonder if you or anyone else can see what is wrong with another similar problem i have. Again remember i migrated from Ms Access to MySql

This is an asp include page, and once again, it needs modifying somewhere, i'm not sure where.

It pulls up the latest 18 articles in a certain category, which are shown in a column, with a title, paragraph, image and link leading to the full news story.

The page doesn't return an error, it just doesn't show anything. ie no records are being pulled out of the database, or if they are, they aren't showing.

I'd appreciate it, if you or anyone could show me what i need to change here, i've copied and pasted, the code which i think is relevant below


Expand|Select|Wrap|Line Numbers
  1.     <% ' Dim SQL_SIDE, RS_SIDE, NID, TITLE, POSTED, NEWS_LISTING, SHOW_HL, MyConn_SIDE, I_SIDE, SUMMARY, CATE_ID, ANAME
  2.  
  3.  
  4.  
  5.  
  6.     ' ------------------------------------------------------------------------------------------------------------------
  7.  
  8.         ' DATABASE CONNECTION
  9.  
  10.         Set MyConn_SIDE = Server.CreateObject("ADODB.Connection")
  11.  
  12.         MyConn_SIDE.Open "Driver={MySQL ODBC 3.51 Driver}; Server=987.564.300.77; uid=aname; pwd=mysql; database=title; option=3; port=3306;"
  13.  
  14.  
  15.         ' NUMBER OF HEADLINES TO SHOW
  16.  
  17.         SHOW_HL = 18
  18.  
  19.         ' Set to 1 if you are using MS Access, set to 2 if you are using MS SQL database
  20.  
  21.         DB_TO_USE_CUSTOM = 3
  22.  
  23.         ' Category ID to pull the articles from
  24.  
  25.         CATE_ID = "108"
  26.  
  27.     ' ------------------------------------------------------------------------------------------------------------------
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.     SELECT CASE DB_TO_USE_CUSTOM
  36.         CASE 1
  37.             SQL_SIDE = "SELECT TOP " & SHOW_HL & " nm_tbl_news.ID AS NID, nm_tbl_news.fldTITLE AS TITLE, nm_tbl_agent.fldNAME AS ANAME, nm_tbl_news.fldPOSTED AS POSTED, fldSUMMARY, nm_tbl_news.fldIMAGE AS NIMAGE FROM nm_tbl_news, nm_tbl_agent WHERE (nm_tbl_agent.ID = nm_tbl_news.fldAID) AND (nm_tbl_news.fldACTIVE=1) AND (Now() BETWEEN fldPOSTED AND fldEXPIRES) AND nm_tbl_news.ID IN (SELECT fldNEWS_ID FROM nm_tbl_news_cate WHERE fldCATE_ID = " & CATE_ID & ") ORDER BY nm_tbl_news.ID DESC"
  38.         CASE 2
  39.             SQL_SIDE = "SELECT TOP " & SHOW_HL & " nm_tbl_news.ID AS NID, nm_tbl_news.fldTITLE AS TITLE, nm_tbl_news.fldPOSTED AS POSTED, fldSUMMARY, nm_tbl_news.fldIMAGE AS NIMAGE FROM nm_tbl_news, nm_tbl_agent WHERE (nm_tbl_agent.ID = nm_tbl_news.fldAID) AND (nm_tbl_news.fldACTIVE=1) AND (GetDate() BETWEEN fldPOSTED AND fldEXPIRES) AND nm_tbl_news.ID IN (SELECT fldNEWS_ID FROM nm_tbl_news_cate WHERE fldCATE_ID = " & CATE_ID & ") ORDER BY nm_tbl_news.ID DESC"
  40.         CASE 3
  41.             SQL_SIDE = "SELECT nm_tbl_news.ID AS NID, nm_tbl_news.fldTITLE AS TITLE, nm_tbl_news.fldPOSTED AS POSTED, fldSUMMARY, nm_tbl_news.fldIMAGE AS NIMAGE FROM nm_tbl_news, nm_tbl_agent WHERE (nm_tbl_agent.ID = nm_tbl_news.fldAID) AND (nm_tbl_news.fldACTIVE=1) AND (Now() BETWEEN fldPOSTED AND fldEXPIRES) AND nm_tbl_news.ID IN (SELECT fldNEWS_ID FROM nm_tbl_news_cate WHERE fldCATE_ID = " & CATE_ID & ") ORDER BY nm_tbl_news.ID DESC LIMIT " & SHOW_HL
  42.     END SELECT                
  43.  
  44.  
  45.     I_SIDE = 0
  46.     Set RS_SIDE = Server.CreateObject("ADODB.Recordset")
  47.     RS_SIDE.LockType   = 1
  48.     RS_SIDE.CursorType = 0
  49.     RS_SIDE.Open SQL_SIDE, MyConn_SIDE    
  50.          WHILE NOT RS_SIDE.EOF 
  51.              NID      = trim(RS_SIDE("NID"))
  52.             TITLE    = trim(RS_SIDE("TITLE"))
  53.             POSTED   = trim(RS_SIDE("POSTED"))
  54.             SUMMARY  = trim(RS_SIDE("fldSUMMARY"))
  55.              AUTHOR  = trim(RS_SIDE("ANAME"))
  56.             IMAGE    = trim(RS_SIDE("NIMAGE")) & ""
  57.             TITLE = PROCESS_SHORTCUTS_INC(False, TITLE)
  58.             SUMMARY = PROCESS_SHORTCUTS_INC(False, SUMMARY)            
  59.             I_SIDE = I_SIDE + 1
  60.             IF I_SIDE =< SHOW_HL   THEN
  61.                 %>
  62.  
  63.  
  64.  
  65.  
  66. <%IF NOT I_SIDE = SHOW_HL THEN%></div>
  67.                     <hr align="JUSTIFY">
  68.                     <div align="justify">
  69.                       <%End If%>
  70.  
  71.  
  72.                       <%
  73.             END IF    
  74.             RS_SIDE.MoveNext
  75.          WEND
  76.     RS_SIDE.Close 
  77.     Set RS_SIDE = Nothing
  78.     MyConn_SIDE.Close
  79.     Set MyConn_SIDE = Nothing
  80.  
  81.     FUNCTION PROCESS_SHORTCUTS_INC(blOPEN, TEXT)
  82.         Dim SQL, RS, strRETURNED_DATA, EOF_VAL, intNUM_COL, intNUM_ROW, intROW_COUNTER, strSIGN, strIMAGE    
  83.         SQL = "SELECT fldSIGN, fldIMAGE FROM nm_tbl_library WHERE fldACTIVE = 1"
  84.         Set RS = Server.CreateObject("ADODB.Recordset")
  85.         RS.LockType   = 1
  86.         RS.CursorType = 0
  87.         RS.Open SQL, MyConn_SIDE    
  88.             IF NOT RS.EOF THEN
  89.                 strRETURNED_DATA = RS.getrows
  90.             ELSE
  91.                 EOF_VAL = True
  92.             END IF    
  93.         RS.close
  94.         Set RS = Nothing   
  95.         IF Not EOF_VAL = True Then
  96.             intNUM_COL=ubound(strRETURNED_DATA,1)
  97.             intNUM_ROW=ubound(strRETURNED_DATA,2)
  98.             FOR intROW_COUNTER = 0 TO intNUM_ROW
  99.                 strSIGN  = Trim(strRETURNED_DATA(0,intROW_COUNTER))
  100.                 strIMAGE = Trim(strRETURNED_DATA(1,intROW_COUNTER))
  101.                 strIMAGE = "<img src='" & strIMAGE & "' border='0' alt='' />"
  102.                 TEXT = Replace(TEXT, strSIGN, strIMAGE)
  103.             NEXT
  104.         END IF                              
  105.         PROCESS_SHORTCUTS_INC = TEXT
  106.     END FUNCTION    
  107.     %>
by the way, do you know a good free database converter that will do the whole database? i'm using a trial version of one programme at the moment, which only pulls up a few records,


Many thanks again.
Oct 19 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
3399
by: Ryan Schefke | last post by:
------=_NextPart_000_0077_01C34C8B.2B90C960 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit ..I just sent this out to the win32 distribution list but no one has replied.can someone on this list please help? The issue should be trivial for experienced MySQL users, I'm just a novice, thanks!
2
4478
by: Kevin Goad | last post by:
Im running Mandrake Linux 9.1 on a Laptop I recently bought, and its purpose its a PHP development machine, and I want to use a MySQL Backend. I think when I was installing MySQL, something got corrupt, and I cannot do anything, it says access denied(And no password was ever set, and I've tried all the "--skip-grant-tables" and all that stuff). Ive tried installing and uninstalling the RPM' packages, but a database I created(called...
0
3953
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest version of this document can be found at: http://prdownloads.sourceforge.net/souptonuts/README_mysql.txt?download
0
1379
by: MBR | last post by:
Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 19 Organization: Arcor NNTP-Posting-Date: 02 Dec 2004 12:46:22 MET NNTP-Posting-Host: a58bf304.newsread4.arcor-online.net X-Trace: DXC=Gl27MQXTJCTD__2dTlB=EkaMXXY;eg@jLYe\NQ\`f2NU8P_mnR6@1cH6TQE]KL?G7HZePceTdIGCVST] X-Complaints-To: abuse@arcor.de Xref: number1.nntp.dca.giganews.com mailing.database.mysql-win32:6848 mailing.database.mysql:143134
17
2911
by: chicha | last post by:
Hey people, I have to convert MS Access 2000 database into mysql database, the whole thing being part of this project I'm doing for one of my faculty classes. My professor somehow presumed I knew db's and gave me long list of things to do with that particular database, first thing being that particular conversion. Truth is that I don't know a first thing about db's, let alone using mysql... I downloaded mysql form www.mysql.com and...
49
3245
by: Mell via AccessMonster.com | last post by:
I created databases on Access 2003 and I want to deploy them to users. My code was also done using 2003. If they have Ms Access 2000 or higher, will they be able to use these dbs with all code, etc? Please explain -- Message posted via http://www.accessmonster.com
0
3484
by: NewbieSupreme | last post by:
I'm using PHPMyAdmin on an Apache2Triad install (latest version; 5.x.x, which installs PHP5 and PHPMyAdmin 2.8 as well). In Access, I exported a table to a text file, tab-delimited, text qualifyer of "none" (this is how I read to do it from newsgroups). When I use the Query window in phpmyadmin to import the text file, it waits a while, then returns an error: #1064 - You have an error in your SQL syntax; check the manual that...
9
106257
by: blacksmoke | last post by:
I got an error... when i wants to create database "usersinfo" Username is 'blacksmoke'... Commandline argumments are: mysql> select user(); : e.g., blacksmoke@localhost -------
11
2584
by: Chad | last post by:
Hi Is it possible to substitute an alternative data source (eg MySQL or SQL Server) into an existing MS-Access application?
0
10599
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10346
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10090
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7635
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6863
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5531
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4308
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3832
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.