Writing Code
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Writing Code
Message Icon Topic: Crystal set location Post Reply Post New Topic
Author Message
donsls
Newbie
Newbie
Avatar

Joined: 22 Oct 2008
Location: Canada
Online Status: Offline
Posts: 7
Quote donsls Replybullet Topic: Crystal set location
    Posted: 22 Oct 2008 at 12:02pm
I have the following code to load a report and set its location (VS 2005). I am passing a report that has a table and an SQL command.

Protected Sub SetDBLogonForReport(ByVal sDbServer As String, _

ByVal sDbName As String, _

ByVal sDbUserName As String, _

ByVal sDbPassword As String, _

ByVal reportName As ReportDocument)

Dim crDatabase As Database

Dim crTables As Tables

Dim crTable As Table

Dim crLogOnInfo As TableLogOnInfo

Dim crConnInfo As New ConnectionInfo

crDatabase = reportName.Database

crTables = crDatabase.Tables

crTables.Reset()

Try

For Each crTable In crTables

With crConnInfo

.ServerName = sDbServer

.DatabaseName = sDbName

.UserID = sDbUserName

.Password = sDbPassword

.IntegratedSecurity = True

End With

crLogOnInfo = crTable.LogOnInfo

crLogOnInfo.ConnectionInfo = crConnInfo

crTable.ApplyLogOnInfo(crLogOnInfo)

crTable.Location = crTable.Location

Next

Catch ex As Exception

Response.Write(ex.Message)

End Try

End Sub

When I pass the report to this function my report runs and I can see the data, but because of the
crTable.Location = crTable.Location
 
It gives me the following error on top of the page.
Logon failed. Details: IM002:[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified Error in File C:\Temp\crystalreport2 {D3AAE90E-582A-4FF2-8FF5-E98454F7AA67}.rpt: Unable to connect: incorrect log on parameters.
 
The moment I comment this, it works without any issues, but when I deploy it and run it from there, I get the following error.
 
Invalid Argument provided. Failed to open a rowset. Error in File C:\Temp\CrystalReport1 {3BEDABA1-0669-43F6-92F1-F9788E07EB97}.rpt: Invalid argument for database
 
If my report has only tables, I don't get the second error, but still it gives me the first error with the setlocation statement.
I even tried the following statements.

'crTable.Location = sDbName & "." & "dbo" & "." & crTable.Location.Substring(crTable.Location.LastIndexOf(".") + 1)

'crTable.Location = crTable.Location.Substring(crTable.Location.LastIndexOf(".") + 1)

 
Still no luck. Can any one help? Any help is greatly appreciated.
 
 
 
 


Edited by donsls - 22 Oct 2008 at 12:08pm
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.