|
-
Nov 10th, 2006, 09:50 PM
#1
Thread Starter
New Member
Connect Crytalreport with password to SQLServer using VB6
Please help me!!!
I using VB6 for my project. Before, I used user "sa" and no have password. Now I feel the orther user can using Access to change may data... so I used user "sa" with an password... with this change i can connect from VB to SQLServer but cann't connect with Crystal Report... My code :
Function ConnectSQL(pstrDtBsName As String) As ADODB.Connection
Dim lstrCntn As String
Dim lstrDSN_Drvr As String, lstrDSN_Srvr As String
Dim lstrDSN_User As String, lstrDSN_PsWd As String
lstrDSN_Drvr = "sqloledb"
lstrDSN_Srvr = "" & TenMay & ""
istrDSN_User = "sa"
lstrDSN_PsWd = "My password"
lstrCntn = "Provider=" & lstrDSN_Drvr & ";"
lstrCntn = lstrCntn & "Data Source=" & lstrDSN_Srvr & ";"
lstrCntn = lstrCntn & "Initial Catalog=" & pstrDtBsName & ";"
lstrCntn = lstrCntn & "User Id=" & istrDSN_User & ";"
lstrCntn = lstrCntn & "Password=" & lstrDSN_PsWd & ";"
Set ConnectSQL = New ADODB.Connection
ConnectSQL.Open lstrCntn
Exit Function
End Function
// Connect to Data
Set My_DB = ConnectSQL("Mydata")
// Connect with Crystal Report
CrystalReport1.ReportFileName = "Myreport.rpt"
CrystalReport1.Connect = My_DB
CrystalReport1.WindowState = crptMaximized
CrystalReport1.Destination = crptToWindow
CrystalReport1.Action = 1
Please help me!!! Thank
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
|