Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot open SQL server error in crystal

Status
Not open for further replies.

hencyt

MIS
Mar 14, 2003
122
US
I am using the report distribution expert to create exe files so the reports can be viewed on other users machines without having to install Crystal. I use it all the time- so I don't think it is the problem.

The report asks for parameters- it allows me to choose the parameters- then it looks like it is loading the report (the viewer comes up) then it thinks for awhile and then it gives me this error "Cannot open SQL server".

I know it is not a permissions issue and I have already tried it on more than one machine and get the same results. The ODBC are setup correctly.

Any ideas?

Thanks in advance,
Sunny
 
Problem Solved. The ODBC was NOT setup correctly after all.

Thanks,
Sunny
 
I am new to Crystal Report and having problem while generating Report in runtime.

I have create ttx file and using that to create report. Once, I am done with both I use vb application to pass the recordset to rport and then view and print..
I am getting blank report......
Here is the code.....
Any help will be appreciated...
Thanks allot...
Please mail to tathagat.dwivedi@gmacrfc.com if u can
----------------------------------
Private Sub Form_Load()

Dim conn As New ADODB.Connection 'CONNECTION TO BROKER QUERIES
Dim rs As New ADODB.Recordset

Dim appn As New CRAXDRT.Application
Dim rpt As New CRAXDRT.Report

CRViewer1.DisplayBorder = True 'MAKES REPORT FILL ENTIRE FORM
CRViewer1.DisplayTabs = False 'THIS REPORT DOES NOT DRILL DOWN, NOT NEEDED
CRViewer1.EnableDrillDown = False 'REPORT DOES NOT SUPPORT DRILL-DOWN
CRViewer1.EnableRefreshButton = False 'ADO RECORDSET WILL NOT CHANGE, NOT NEEDED
Do While CRViewer1.IsBusy 'ZOOM METHOD DOES NOT WORK WHILE
DoEvents 'REPORT IS LOADING, SO WE MUST PAUSE
Loop
Dim sConnectStr As String
Dim sid, user, passwd As String
sid = "shrd"
user = "tdwived"
passwd = "tdwived"
On Error GoTo ErrorHandler

sConnectStr = "Provider=MSDAORA;Data Source= " & sid & ";User ID=" & user & ";Password=" & passwd & ""
conn.CursorLocation = adUseClient
conn.CommandTimeout = 60

conn.Open sConnectStr
MsgBox "connected"
rs.Open &quot;SELECT ASSET_SEQ_ID,ASSET_STATUS_CODE FROM ASSET WHERE rownum <=2&quot;, conn, adOpenStatic, adLockReadOnly

Set rpt = appn.OpenReport(&quot;C:\Project\Rms\Release\Feb-2004\Crystal Report\CrystalReportWithDdtFile.rpt&quot;)
MsgBox rs.Fields(1).Value
rpt.Database.Tables.Item(1).SetLogOnInfo &quot;SHRD.RFC.COM&quot;, &quot;&quot;, &quot;TDWIVED&quot;, &quot;TDWIVED&quot;
'rpt.Database.Tables(1).SetLogOnInfo &quot;&quot;, &quot;shrd&quot;, &quot;tdwived&quot;, &quot;tdwived&quot;

'rpt.DiscardSavedData
rpt.Database.SetDataSource rs, 3, 1
CRViewer1.ReportSource = rpt

CRViewer1.ViewReport

Do While CRViewer1.IsBusy 'ZOOM METHOD DOES NOT WORK WHILE
DoEvents 'REPORT IS LOADING, SO WE MUST PAUSE
Loop 'WHILE REPORT LOADS.

CRViewer1.Zoom (100)
'CRViewer1.PrintReport
'CRViewer1.Visible = True

rs.Close 'ALL BELOW HERE IS CLEANUP
Set rs = Nothing

conn.Close
Set conn = Nothing
' -----------
Exit Sub
ErrorHandler:
MsgBox (Err.Number & &quot;:&quot; & Err.Description)
End Sub
 
Ok, here's some code that's clipped from a sample app that runs against an ADO recordset obtained from SQL Server. The ADO recordset is referenced as &quot;rs&quot; in the code:

Dim crDB As CRAXDRT.Database
Dim crTable As CRAXDRT.DatabaseTable
Dim crApp As New CRAXDRT.Application
Dim crRpt As CRAXDRT.Report


Set crRpt = crApp.OpenReport(App.Path & &quot;/&quot; & cSalesOrders)
'Get rid of any data saved in the report
crRpt.DiscardSavedData

'Get the Database object
Set crDB = crRpt.Database

'an ado report should only have on table, so we can get it
'directly using the Item property of the Tables collection
Set crTable = crDB.Tables.Item(1)

'Pass the ado recordset to the database table
crTable.SetDataSource rs, 3

'Now read the records into the report before the rs goes out of scope
crRpt.ReadRecords


The calls after this would be to the viewer control, setting the report source and viewing the report. It appears that you need to use the ReadRecords method to load the data into the report. Also, you've remarked out the DiscardSavedData method, which is recommended.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top