Results 1 to 6 of 6

Thread: Invalid Connection String???

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2003
    Posts
    86

    Question Invalid Connection String???

    Code:
    Set ConnectionInfo = crReport.Database.Tables(1).ConnectionProperties
                
    ConnectionInfo.Item("DSN") = dsn_name
    ConnectionInfo.Item("User ID") = user_name
    ConnectionInfo.Item("Password") = pass_word
    When I try to run a report setting the Connection Info as described above,it throws an Error message "Invalid Connection String"
    Can anybody please tell me where I went wrong.
    Thanks

  2. #2
    Hyperactive Member ARPRINCE's Avatar
    Join Date
    Mar 2003
    Location
    Pinoy in NJ
    Posts
    381
    You're missing some parameters. You can try something like below:

    VB Code:
    1. With crReport.Database.Tables(1).ConnectionProperties
    2.       .Item("Provider") = "your_provider"
    3.       .Item("Data source") = "your_server"
    4.       .Item("Initial Catalog") = "your_database"
    5.       .Item("User ID") = "user_id"
    6.       .Item("Password") = "user_password"
    7.    End With

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2003
    Posts
    86
    Thank you for replying to my query.On following your advice,I specified :

    Code:
    With crReport.Database.Tables(1).ConnectionProperties
          .Item("Provider") = "sqloledb"
          .Item("Data source") = "your_server"
          .Item("Initial Catalog") = "your_database"
          .Item("User ID") = "user_id"
          .Item("Password") = "user_password"
        End With
    But,it is showing error message : "Method value of 'iConnection Property' Failed" and,showing me error in Provider.I have used the same provider for calling the DB and it works fine.Do you think for CR,it needs to be called in a different way?
    Thanks



    *EDIT*
    On using the below specified code,the Report is visible.
    Thanks
    Code:
    With crReport.Database.Tables(1).ConnectionProperties
          .Item("DSN") = "your_server"
          .Item("User ID") = "user_id"
          .Item("Password") = "user_password"
        End With

  4. #4
    Hyperactive Member ARPRINCE's Avatar
    Join Date
    Mar 2003
    Location
    Pinoy in NJ
    Posts
    381
    What CR Version do you have? Also, I forgot to mention that the above example uses OLE DB as a connection and I assumed that yours uses the same type of a connection.

    If true, you can go to your report's database expert and check the properties of your connection. It should tell you the right provider name and other properties values to use.

    Otherwise, can you post your report form's code?

  5. #5

    Thread Starter
    Lively Member
    Join Date
    May 2003
    Posts
    86

    Thumbs up

    Thank you for replying back. I had an ODBC(RDO) setup and,your suggestion showed me the right way to work it out.

  6. #6
    New Member
    Join Date
    Jun 2003
    Posts
    6
    Hi NewbieVB2003


    i had the same problem and finally found the way to do it.
    but if you have more than one tables in your report (like i have)
    you could do the following....

    Report.DiscardSavedData

    For i = 1 To Report.Database.Tables.Count
    Report.Database.Tables(i).ConnectionProperties.DeleteAll
    Report.Database.Tables(i).ConnectionProperties.Add "DSN", newDSN
    Report.Database.Tables(i).ConnectionProperties.Add "User ID", newID
    Report.Database.Tables(i).ConnectionProperties.Add "Password", newPWD
    Next i

    it is also usefull sometimes, before you try anything with your report to call the DiscardSavedData function
    klain main froilain...

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