|
-
Jan 13th, 2003, 01:56 PM
#1
Thread Starter
Lively Member
Changing SQL Database @ Runtime [RESOLVED]
I am sure this is somewhere in the forums but I can't find a definitive answer. I have an app that is using the Crystal Report Viewer to display some reports. I'm hitting a SQL server 2000 Database. My problem is getting these reports to run on a database with a different name.
I sent my App to a friend of mine and the reports won't run. I set up my instance of SQL Server with an Alias and he didn't set his up that way. Also, our databases are named differently. The reports run perfectly on my machine but when he tried to run them he gets "Server has not yet been opened."
I have looked at the knowlege base at Crystal Decisions and have tried some of their suggestions with the reports.
Here's a snippet of my current code.
VB Code:
If crApp Is Nothing Then
Set crApp = New CRAXDRT.Application
Call crApp.LogOnServerEx("p2ssql.dll", DBConn.Server & IIf(LenB(Trim$(DBConn.Alias)) > 0, "\" & DBConn.Alias, ""), _
DBConn.DatabaseName, DBConn.UserName, DBConn.UserPass, Chr(34) & CStr(CRDatabaseType.crSQLDatabase) & Chr(34), DBConn.ConnString)
End If
Load rptForm
Set rpt = crApp.OpenReport(rptPath)
I thought that the LogOnServer and LogonServerEx were supposed to be the way to change data sources. Any help is appreciated. Thanks.
Last edited by Harvester; Jan 13th, 2003 at 03:12 PM.
-
Jan 13th, 2003, 03:12 PM
#2
Thread Starter
Lively Member
Figured it out.
I figured this one out.
You apparently have to set the logon info for each table you are working with... you learn something new every day.
VB Code:
For i = 1 To rpt.Database.Tables.Count
Call rpt.Database.Tables(i).SetLogOnInfo(DBConn.Server & IIf(LenB(Trim$(DBConn.Alias)) > 0, "\" & DBConn.Alias, ""), DBConn.DatabaseName, DBConn.UserName, DBConn.UserPass)
Next i
-
Jan 13th, 2003, 03:53 PM
#3
If your report contains sub-reports you need to change the login info as well (at least using version 8.0 and CRPEAuto).
-
Sep 8th, 2006, 02:08 PM
#4
New Member
Re: Changing SQL Database @ Runtime [RESOLVED]
I am using the same code but data is still pulling from the original db. Why?
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
|