+ Reply to Thread
Results 1 to 8 of 8

Problem with ADODB.Connection and Insert Command

  1. #1
    Registered User
    Join Date
    09-06-2012
    Location
    Kaiserslautern,Germany
    MS-Off Ver
    2007
    Posts
    19

    Post Problem with ADODB.Connection and Insert Command

    Hi everyone!

    I can not understand why this code does not work.
    SQLString = insert into Positions (FundName,SubFund,Prime_Broker_Clearing_Broker) Values ('A','A_AA','WW') , where Values are just strings. I tried different combinations, but it didn't work.
    SQLConnection(DBSource) - This function sets connection, it works properly I checked with other simle task, i can extract the last date from DB

    In my case iRecAffected is always 0.


    Please Login or Register  to view this content.


    Thank you for your help!

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Problem with ADODB.Connection and Insert Command

    Can you post the rest of the code?

    What are the data types of the field you are updating?

    What database are you connecting to?

  3. #3
    Registered User
    Join Date
    09-06-2012
    Location
    Kaiserslautern,Germany
    MS-Off Ver
    2007
    Posts
    19

    Re: Problem with ADODB.Connection and Insert Command

    Hi, Norie
    thank you for your answer. The whole code is really big. First I read the data from Excel and build up SQLStrings.
    SQLStrings are correct, they contain just fields and values.
    There is the function which establishes connection.
    Please Login or Register  to view this content.

    DBSource is the path to Access database.

    Thanks!

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Problem with ADODB.Connection and Insert Command

    It's kind of the part that builds the SQL that I wanted to see.

    You say they are correct?

    Did you check them in the database?

  5. #5
    Registered User
    Join Date
    09-06-2012
    Location
    Kaiserslautern,Germany
    MS-Off Ver
    2007
    Posts
    19

    Re: Problem with ADODB.Connection and Insert Command

    Yes, it is just the function that returns strings and they look like this:

    SQLString = insert into Positions (FundName,SubFund,Prime_Broker_Clearing_Broker) Values ('A','A_AA','WW') (I printed it in excel file so I am sure it looks like this)

    and then this string is passed to Sub SQLCommand(SQLString As String, DBSource As String) together with the path to the DB.

    The funny thing that the database was working till some day in August and since that time no updates were made because of this technical reason.
    And now my task is to figure out why...I checked every function and I am puzzled. But I have never worked with this stuff before, so I used some internet tutorials and according to them it should work..so I guess I am missing something important here..

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Do you have access to run a query manually?

    If you do check the SQL by trying to run it.

    That's what I do when faced with something like this.
    If posting code please use code tags, see here.

  7. #7
    Registered User
    Join Date
    09-06-2012
    Location
    Kaiserslautern,Germany
    MS-Off Ver
    2007
    Posts
    19

    Re: Problem with ADODB.Connection and Insert Command

    I will try, thank you!

    May be you could advise me some manual/tutorials in internet, so I can learn more about ADODB, etc...
    I will really appreciate.

  8. #8
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Problem with ADODB.Connection and Insert Command

    I would suggest removing the On Error Resume Next line before you execute the command-it may help track down the problem
    Josie

    if at first you don't succeed try doing it the way your wife told you to

+ 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