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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Database Connection Through VB

Status
Not open for further replies.

Rob2k2

Technical User
Oct 14, 2002
36
0
0
GB
I have created several crystal reports and I now wish to write a visual basic frontend to view the reports.

The reports import data using two sql queries from a single SQL database.

Here is the SQL code I have in VB at the moment.

Public Appn As CRAXDRT.Application
Public cReport As CRAXDRT.Report

Private Sub ShowReportBtn_Click()
Select Case ReportList.ListIndex
Case 0
Case 1
Case 2
Case 3
Case 4
Case 5

Set Appn = CreateObject("CrystalRunTime.Application")

Set cReport = Appn.OpenReport("C:\Documents and Settings\Robert\Desktop\Reports Main Page\Reports\Talk Statistics.rpt")

ReportViewFrm.CRViewer91.ReportSource = cReport

ReportViewFrm.CRViewer91.ViewReport

ReportViewFrm.CRViewer91.Zoom (90)

ReportMainFrm.Hide
ReportViewFrm.Show

Case 6
End Select

End Sub

What I need to do is logon to the SQL server so I can refresh the report data.

Could someone post what has to be declared and the syntax to logon to the SQL server.
 
I use Delphi to achieve the same fundamentally.
I make use of :
CRReport.Database.Tables.SetLogOnInfo('SERVER-NAME', 'DATABASE-NAME', 'USER-NAME', 'PASSWORD');
... AND ....
CRReport.Database.Tables.Location = '[DATABASE-NAME].[TABLE-NAME]';

Admittedly this is Delphi code but the principal would be the same and potentially the code would be simliar.
I hope that I've helped a little

Steve
 
Hi

In VB, insert these two lines just after open report

rpt.Database.LogOnServer "pdssql.dll", "dbServerName", "DbName", "UserName", "Password"

rpt.Database.Verify

Hope this can help!

Kan


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top