SaxonWica
asked on
Changing Connection - Visual Basic 6 - Using Connection String
Hello there,
I'm currently using Crystal Report 9 Enterprise.
I've seen the previous topics about changing connection programatically using DSN / ODBC. What I want to ask if it is possible to use standard connection string from Visual basic 6 ?
For example, I have created a report using my local SQL 2000 server named SERVER-A. Now I'd like to deploy my report to other computer, which use another SQL 2000 server named SERVER-B with similar database. And I use datalink to set visual basic connection string. Is it possible for Visual Basic to transfer its connection string to Crystal Report ?
I have also tried to make a report using a datalink file, it works perfectly fine, but I encountered some 'annoying' problem. I found that Crystal report is unable to use Datalink file in relative path. How to change the datalink path of the report from Visual Basic ?
Thank you for your kind and helpful answers.
Regards
Saxon Wica
I'm currently using Crystal Report 9 Enterprise.
I've seen the previous topics about changing connection programatically using DSN / ODBC. What I want to ask if it is possible to use standard connection string from Visual basic 6 ?
For example, I have created a report using my local SQL 2000 server named SERVER-A. Now I'd like to deploy my report to other computer, which use another SQL 2000 server named SERVER-B with similar database. And I use datalink to set visual basic connection string. Is it possible for Visual Basic to transfer its connection string to Crystal Report ?
I have also tried to make a report using a datalink file, it works perfectly fine, but I encountered some 'annoying' problem. I found that Crystal report is unable to use Datalink file in relative path. How to change the datalink path of the report from Visual Basic ?
Thank you for your kind and helpful answers.
Regards
Saxon Wica
ASKER
Yes, I built the report using ADO type connection. But how do I change the connection string from Visual basic?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I've checked your given link, but it seems that it uses insertable designer component in Visual Basic 6, not from a separate rpt files. Note that this feature only available in version 8.5, not in version 9 (As far as I know, please correct me if I am wrong).
Thank you very much.
Regards
Thank you very much.
Regards
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Dear Sara,
Your code almost meet my expected result, but with one exception.
What if I just want to pass the connection string, not the recordset?
By using your code, if I did some changes on the report (e.g. adding some more table), I think I must change the recordset from VB too. Isn't that correct?
Thank you very much
Your code almost meet my expected result, but with one exception.
What if I just want to pass the connection string, not the recordset?
By using your code, if I did some changes on the report (e.g. adding some more table), I think I must change the recordset from VB too. Isn't that correct?
Thank you very much
ASKER
http://support.businessobjects.com/communityCS/TechnicalPapers/cr_rdc9_connectionproperties.pdf.asp?ref=devzone_comaspzone_main
I have just found the link, and it also helps a lot
'Declare a Connection Info Object
Dim ConnectionInfo As CRAXDRT.ConnectionProperti es
'Set the Connection Info to Connection Properties of
‘the table object
Set ConnectionInfo = Report.Database.Tables(1). Connection Properties
'Set the OLE DB Provider
ConnectionInfo.Item(“Provi der”) = “SQLOLEDB”
'Set the physical server name
ConnectionInfo.Item(“Data Source”) = “Server name”
'Set the database name
ConnectionInfo.Item(“Initi al Catalog”) = “Database name”
'Set the integrated security
ConnectionInfo.Item(“Integ rated Security”) = True
'Set the user name
ConnectionInfo.Item(“User ID”) = “User name”
'Set the password
ConnectionInfo.Item(“Passw ord”) = “Password”
'Set the fully qualified table name if different from
‘the original data source
Report.Database.Tables(1). Location = “database.owner.tablename”
But it still doesn't answer my question if I just want to use a connection string, for example :
"Data Source=eiffel; Initial Catalog=SmartCard; Integrated Security=SSPI"
Thank you very much
Regards
I have just found the link, and it also helps a lot
'Declare a Connection Info Object
Dim ConnectionInfo As CRAXDRT.ConnectionProperti
'Set the Connection Info to Connection Properties of
‘the table object
Set ConnectionInfo = Report.Database.Tables(1).
'Set the OLE DB Provider
ConnectionInfo.Item(“Provi
'Set the physical server name
ConnectionInfo.Item(“Data Source”) = “Server name”
'Set the database name
ConnectionInfo.Item(“Initi
'Set the integrated security
ConnectionInfo.Item(“Integ
'Set the user name
ConnectionInfo.Item(“User ID”) = “User name”
'Set the password
ConnectionInfo.Item(“Passw
'Set the fully qualified table name if different from
‘the original data source
Report.Database.Tables(1).
But it still doesn't answer my question if I just want to use a connection string, for example :
"Data Source=eiffel; Initial Catalog=SmartCard; Integrated Security=SSPI"
Thank you very much
Regards
What I was telling you is that, Instead of the database connection and fectch the records from database you can directly assign the recordset results to the report and run it.
Rgds
Sara
Rgds
Sara
ASKER
Well, it worked, but if I change any design from the report (e.g. adding more tables) means I have to change the recordset results too, right? That is what I am trying to prevent.
I just want to change the report only, but nothing to do with the coding from visual basic, which means I only need the connection string. Is there a way to do this?
Thank you
I just want to change the report only, but nothing to do with the coding from visual basic, which means I only need the connection string. Is there a way to do this?
Thank you
Unfortunately, when you change the the connection string, you also have to reset all information for the database and tables. Thus if your change the design (add a table, delete a table) the application will have to reflect the change.
I was able to avoid this problem by creating a small development LAN that we setup identically to the production LAN. Server is named the same, drives are mapped the same, reports are in the same directories, etc. We also use integrated securty & TRUSTED CONNECTIONS which eliminates the need to log into the database. If you can get the dev environment to be the same as the production environment (this does require a separate LAN) then you can change the reports any way you wish and the users never see a problem.
mlmcc
I was able to avoid this problem by creating a small development LAN that we setup identically to the production LAN. Server is named the same, drives are mapped the same, reports are in the same directories, etc. We also use integrated securty & TRUSTED CONNECTIONS which eliminates the need to log into the database. If you can get the dev environment to be the same as the production environment (this does require a separate LAN) then you can change the reports any way you wish and the users never see a problem.
mlmcc
ASKER
Dear mlmcc,
I think that's also the only way to do it. Thank you for answering my questions. I think I have to split the points, since you both really helped me a lot. I hope you two don't mind
Regards
I think that's also the only way to do it. Thank you for answering my questions. I think I have to split the points, since you both really helped me a lot. I hope you two don't mind
Regards
Glad i could help
mlmcc
mlmcc
Its our pleasure to help each other. I'll do more R&D if there is anything that i got, I shall post it.
Rgds
Sara
Rgds
Sara
mlmcc