Results 1 to 7 of 7

Thread: MySQL and Query (Allias) ***RESOLVED***

Threaded View

  1. #1

    Thread Starter
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Resolved MySQL and Query (Allias) ***RESOLVED***

    Can someone tell me why I am getting an error for the the following sql statement when I execute it against a MySQL Database. This sql statement works great with MSSQL and Access:

    VB Code:
    1. Dim strFieldName as String
    2. Dim strTableName as String
    3.  
    4. strFieldName = "MyFieldName"
    5. strTableName = "MyTableName"
    6.  
    7. strSQL = "SELECT " & strFieldName & " as FieldName " '<==Aliasing MyFieldName as fieldname
    8. strSQL = strSQL & "FROM " & strTableName & " "

    then I attempt to Add a new record into the table:

    VB Code:
    1. rs.AddNew
    2.         strValue = Me.Text1.Text
    3.         rs!FieldName = strValue & ""
    4.         rs.Update  '<====This is the line I get the error on

    I get the following error message: Error -214721900 (Unknown column 'fieldname' in 'field list)

    Am I to assume that MySQL doesn't allow you to allias fieldnames?

    If I change the fieldname to the following:

    VB Code:
    1. Dim strFieldName as String
    2. Dim strTableName as String
    3.  
    4. strFieldName = "MyFieldName"
    5. strTableName = "MyTableName"
    6.  
    7. strSQL = "SELECT " & strFieldName & " " 'as FieldName " <==Aliasing MyFieldName as fieldname
    8. strSQL = strSQL & "FROM " & strTableName & " "

    VB Code:
    1. rs.Fields(0).Value = strValue & ""

    it works fine, any ideas??

    P.S. I am using mysql-4.1.12-win32 version
    Last edited by Mark Gambo; May 30th, 2005 at 07:38 PM.
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width