|
-
Jul 19th, 2000, 12:55 PM
#1
Thread Starter
New Member
Please help, I have an SQL database and I want to use VB to log on, return a recordset that will be previewed in Crystal Reports.
However, I get an error message all the time "login failed for user "sa"" and then another one "cannot open SQL server".
What is wrong??? (The password is correct, I am able to get a good recordset in return). Do I lose the connection somewhere??
Here is my code:
Public Conn As New ADODB.Connection
Public rs As New ADODB.Recordset
Public err As ADODB.Error
Public str As String
---------------------------------------
Public Function crystal()
Dim application As CRPEAuto.application
Dim Report As CRPEAuto.Report
str = "select * from performance where accno=400002"
'login
Conn.Open "Driver=SQL Server;Server=UNREAL;Database=performance;User ID=sa;Password=laser"
Set rs = Conn.Execute(str)
'test for recordset (works fine)
rs.MoveFirst
MsgBox rs(1).Value
'test for connection (works fine)
If Conn.State = adStateOpen Then
MsgBox "OK"
Else
MsgBox "Not OK"
End If
'Have not even tried the SetPrivateData yet since the Preview doesn't work...
'report.Database.Tables("ado").SetPrivateData 3, rs
Set application = CreateObject("Crystal.CRPE.Application")
Set Report = application.OpenReport("H:\vbkul\perf2\perf2port.rpt")
'This is where it fails
Report.Preview
MsgBox "Here is the report"
Set Report = Nothing
Set application = Nothing
rs.Close
Conn.Close
End Function
---------------------------------------------------
If there is anybody out there that could help I would be very happy!!!
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
|