|
-
Aug 21st, 2007, 02:25 AM
#1
Thread Starter
Fanatic Member
How to change DSN at run time
Dear All,
I am using VB6+ CR9, how to change DSN at run time? ..
Please help
TIA
Winanjaya
-
Aug 29th, 2007, 11:17 AM
#2
Addicted Member
Re: How to change DSN at run time
Have you found the answer to this question? .... I would like to know too
-
Aug 29th, 2007, 09:13 PM
#3
Thread Starter
Fanatic Member
Re: How to change DSN at run time
not yet
-
Aug 29th, 2007, 10:06 PM
#4
Re: How to change DSN at run time
 Originally Posted by Winanjaya
Dear All,
I am using VB6+ CR9, how to change DSN at run time? ..
Please help
TIA
Winanjaya
I don't understand your question, could you elaborate?
Regards,
Mark
Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."
-
Aug 30th, 2007, 02:11 AM
#5
Addicted Member
Re: How to change DSN at run time
This is how to change DSN at runtime:
From the CrystalReport.New event which you will find in the CrystalRepost.vb file add the following line:
Code:
Public Sub New()
MyBase.New()
Logon(Me, "DSN Name", "Database", "UserName", "Password")
End Sub
then create a module within your appliaciation call "modCrystalReports" and add the following code
Code:
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Module modCrystalRports
''' <summary>
''' The Logon method iterates through all tables
''' </summary>
''' <param name="cr"></param>
''' <param name="server"></param>
''' <param name="db"></param>
''' <param name="id"></param>
''' <param name="pass"></param>
''' <returns></returns>
''' <remarks></remarks>
Public Function Logon(ByVal cr As ReportDocument, ByVal server As String, ByVal db As String, ByVal id As String, ByVal pass As String) As Boolean
Dim ci As New ConnectionInfo()
Dim subObj As SubreportObject
ci.ServerName = server
ci.DatabaseName = db
ci.UserID = id
ci.Password = pass
If Not (ApplyLogon(cr, ci)) Then
Return False
End If
Dim obj As ReportObject
For Each obj In cr.ReportDefinition.ReportObjects()
If (obj.Kind = ReportObjectKind.SubreportObject) Then
subObj = CType(obj, SubreportObject)
If Not (ApplyLogon(cr.OpenSubreport(subObj.SubreportName), ci)) Then
Return False
End If
End If
Next
Return True
End Function
''' <summary>
''' Apply Login
''' </summary>
''' <param name="cr"></param>
''' <param name="ci"></param>
''' <returns></returns>
''' <remarks></remarks>
Public Function ApplyLogon(ByVal cr As ReportDocument, ByVal ci As ConnectionInfo) As Boolean
Dim li As TableLogOnInfo
Dim tbl As Table
' for each table apply connection info
For Each tbl In cr.Database.Tables
li = tbl.LogOnInfo
li.ConnectionInfo = ci
tbl.ApplyLogOnInfo(li)
' check if logon was successful
' if TestConnectivity returns false,
' check logon credentials
If (tbl.TestConnectivity()) Then
'drop fully qualified table location
If (tbl.Location.IndexOf(".") > 0) Then
tbl.Location = tbl.Location.Substring(tbl.Location.LastIndexOf(".") + 1)
Else
tbl.Location = tbl.Location
End If
Else
Return False
End If
Next
Return True
End Function
End Module
That should do it
-
Aug 30th, 2007, 02:24 AM
#6
Junior Member
Re: How to change DSN at run time
how to handle multi user application...in vb6.0/sql 2000
i want to restrict other users when one user is editing the one record say Invoice. no. 0001
-
Aug 30th, 2007, 02:27 AM
#7
Re: How to change DSN at run time
 Originally Posted by udaywalve
how to handle multi user application...in vb6.0/sql 2000
i want to restrict other users when one user is editing the one record say Invoice. no. 0001
I think you posted to the wrong thread, becuase you can't edit any data via Crystal Reports.
Regards,
Mark
Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."
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
|