Author |
Message |
jpaulino
Newbie
Joined: 06 Jun 2007
Location: United States
Online Status: Offline
Posts: 2
|
Topic: Deployment logon problem Posted: 06 Jun 2007 at 11:53pm |
If anyone could help that would be great. I bought the book a while ago and it helped quite a bit. I am now in the deployment stage of my application and I'm having a problem viewing the reports on the target machine. I need to change the server and user credentials in run time, and I followed the book but it's giving me some problems, here's the code:
Dim r as ReportDocument r.Load("c:\report.rpt")
Dim table As Table Dim li As CrystalDecisions.Shared.TableLogOnInfo
For Each table In r.Database.Tables li = table.LogOnInfo With li.ConnectionInfo .DatabaseName = database .ServerName = server .UserID = user .Password = password End With table.ApplyLogOnInfo(li) Next crystalviewer.ReportSource = r
But when I try and run this I get the messagebox "Logon failed. Please try again". I am sure that I have all the credentials correct. The server is MySQL 5.
Here's what confuses me. If I create the report using "192.168.1.118"(my server ip) for all my tables, when I run the report on the target machine the report runs fine. But if I create the report with "localhost" and then run the above code to change the server name in run time it will never be able to log on.
This might me a deployment issue(because of the merge module and keycode), but I think I did that all right(according to the book).
Someone please help, it seems that somehow I can't change the server name for the report.
Any help would be appreciated, Jose
|
IP Logged |
|
BrianBischof
Admin Group
Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
|
Posted: 07 Jun 2007 at 12:22am |
Hi Jose,
You need to read pages 364-366. Your code is only good for setting the login id and the password. Code for changing the server is listed there (specifically you need to set the Location property - but read the whole section for details).
|
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
|
IP Logged |
|
jpaulino
Newbie
Joined: 06 Jun 2007
Location: United States
Online Status: Offline
Posts: 2
|
Posted: 07 Jun 2007 at 10:11am |
Firstly, I appreciate your quick response. Ok so I read and re-read the section and tried a various assortment of permutations of code and still to no avail.
I don't know if it's because I have MySQL and not SQL Server. but here's the current code I have:
Private Function SetLogonInfo(ByRef r As ReportDocument, ByVal user As String, ByVal password As String, ByVal server As String, ByVal database As String) As Boolean Dim table As Table Dim li As CrystalDecisions.Shared.TableLogOnInfo Dim ci As New CrystalDecisions.Shared.ConnectionInfo
Try ci.ServerName = server ci.DatabaseName = database ci.UserID = user ci.Password = password
For Each table In r.Database.Tables li = New TableLogOnInfo(table.LogOnInfo) li.ConnectionInfo = ci table.ApplyLogOnInfo(li) If table.TestConnectivity = False Then MsgBox("error connecting to table " & table.Name) End If table.Location = table.Name Next Catch ex As Exception Return False End Try
Return True End Function
while debugging I am watching the table.LogonInfo object, and when ApplyLogonInfo is called there is no changes to it. Hence TestConnectivity returns false and then when table.location is assigned I get the following error: {"Logon failed. Details: HYT00:[MySQL][ODBC 3.51 Driver]Can't connect to MySQL server on 'localhost' (10061) Error in File C:\DOCUME~1\Jose\LOCALS~1\Temp\test_inv {E1EBDD6B-D3AD-4C60-9096-CEDAB06799E4}.rpt: Unable to connect: incorrect log on parameters."}
Which reveals that the server has not changed.
I think it all hinges on the ApplyLogonInfo method that doesn't apply the logoninfo. could it be the connectioninfotype property of connectioninfo object?
I am lost and would appreciate more guidance.
|
IP Logged |
|
BrianBischof
Admin Group
Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
|
Posted: 07 Jun 2007 at 11:29am |
That's an interesting error message. It tells me that CR attempts to login up changing the Location property. I never knew that. Anyway, yes, using MySql changes things. I only know SQL Server. After you set the Location property, does it actually change or does it ignore your changes? Also, I would be curious as to what would happen if you set the Location property PRIOR to calling AppLogOnInfo(). It will probably still crash, but its a low risk test.
|
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
|
IP Logged |
|
|