|
-
Jun 1st, 2003, 07:02 PM
#1
Thread Starter
Lively Member
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
-
Jun 3rd, 2003, 08:04 AM
#2
Hyperactive Member
You're missing some parameters. You can try something like below:
VB Code:
With crReport.Database.Tables(1).ConnectionProperties
.Item("Provider") = "your_provider"
.Item("Data source") = "your_server"
.Item("Initial Catalog") = "your_database"
.Item("User ID") = "user_id"
.Item("Password") = "user_password"
End With
-
Jun 3rd, 2003, 10:33 AM
#3
Thread Starter
Lively Member
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
-
Jun 3rd, 2003, 11:20 AM
#4
Hyperactive Member
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?
-
Jun 3rd, 2003, 05:59 PM
#5
Thread Starter
Lively Member
Thank you for replying back. I had an ODBC(RDO) setup and,your suggestion showed me the right way to work it out.
-
Jun 4th, 2003, 04:56 AM
#6
New Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|