+ Reply to Thread
Results 1 to 7 of 7

exporting data to mysql is giving errors

  1. #1
    Registered User
    Join Date
    06-07-2013
    Location
    Romania
    MS-Off Ver
    Excel 2007
    Posts
    6

    exporting data to mysql is giving errors

    hi,
    i'm trying to make some code i found in a tutorial work.
    i have a mysql database, which i use with another application. i've made a new excel document with the same structure as the table in the database, and i'm trying to send the data there.
    here is the code:

    Please Login or Register  to view this content.
    the first part seems to work. doesn't return any errors at least.
    The insertData sub however, returns "Run-time error 424: object required". In this case i renamed the sheet i was working with, after writing the code, and this probably caused the error.
    I tried doing the whole thing all over again, in a new document, without renaming the sheet, and now the error i get is: "Run-time error '-2147217887 (80040e21)': Automation Error"

    can anyone spot a problem? on the site where i got the tutorial, the comments seem to say the code works for most people, however, a few complained about the same error, and got no answer that helped.

    thank you for your time

    maybe i should add a link to the tutorial: http://www.heritage-tech.net/908/ins...cel-using-vba/
    Last edited by john12345678; 06-07-2013 at 05:11 AM.

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: exporting data to mysql is giving errors

    Put Debug.Print strSQL after you have generated your sql string and copy and paste it into your sql tool, phpMyAdmin/MySQL workbench etc and see if it is valid sql - I suspect it isn't, you're missing an apostrophe here:
    Please Login or Register  to view this content.
    And is pid really a string?

    If it is valid, try replacing
    Please Login or Register  to view this content.
    with:
    Please Login or Register  to view this content.
    and see if it makes any difference

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Why is the function 'esc' in the middle of a sub?
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    06-07-2013
    Location
    Romania
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: exporting data to mysql is giving errors

    thank you for the answer.
    as far as i can tell, the first thing you said was right, sql string not valid.
    i tried to make this work adapted to my own database and table, which has a different number of columns and different types of data, if that matters.
    Now i've remade the entire thing again, this time following the instructions from the tutorial exactly, creating the database and table with the structure given there, so i wouldn't have to modify the code, and it all worked. Now i just have to figure out how to do the changes i need. (yes, i'm new to sql)

  5. #5
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: exporting data to mysql is giving errors

    Is there a particular reason you've chosen mysql, mssql might be a tad easier to learn sinve it will send back syntax errors I'd your sql is invalid. I put together an example of this if you search for threads started by me, you'll find it

  6. #6
    Registered User
    Join Date
    06-07-2013
    Location
    Romania
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: exporting data to mysql is giving errors

    Quote Originally Posted by Kyle123 View Post
    Is there a particular reason you've chosen mysql, mssql might be a tad easier to learn sinve it will send back syntax errors I'd your sql is invalid. I put together an example of this if you search for threads started by me, you'll find it
    my project involves sending the data i work with in excel to an android phone... and since i've never done this before, i'm working with what i can figure out from tutorials and forums... and i have the part where i request data from the database and receive it on my application working, using wamp and eclipse. Now sending data to the database works as well, and i'm working on "targeting" the data i need to be sent: temperature values from a DAQ system.
    I hope what i wrote makes some sense to you:P...

  7. #7
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: exporting data to mysql is giving errors

    Yeah, makes sense

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1