|
-
May 10th, 2006, 08:39 AM
#1
Thread Starter
Junior Member
New To Cystal Reports
I Want To Know How I Can Connect To My Database In Crystal Reports. Which Option I Should Select? Database Is In Mssql Sever 2000.
Thnx In Advance
-
May 10th, 2006, 10:12 AM
#2
Frenzied Member
Re: New To Cystal Reports
you are going to have to make a ODBC connection to your SQL database.
-
May 15th, 2006, 09:14 PM
#3
Member
Re: New To Cystal Reports
Dim crApp As New CRAXDRT.Application
Dim crRe As New CRAXDRT.Report
Private Sub FormLoad()
Set crRe = crApp.OpenReport(App.Path & "\Report\customers.rpt")
LoadData
End Sub
Private Sub LoadData()
Dim cmdApp As Adodb.Command
Dim fld As FieldObject
Set cmdApp = New adodb.Command
cmdApp.ActiveConnection = Connect.cn
cmdApp.CommandTimeout = 15
cmdApp.CommandType = adCmdText
cmdApp.CommandText = "Select customerID, CustomerName from Customers Where CustomerCountry='VietNam'"
cmdApp.Execute
crRe.Database.AddADOCommand Connect.cn, cmdApp
Set fld = crRe.Sections(3).AddFieldObject("{ADO.customerID}", crRe.customerID.Left, crRe.customerID.Top)
SetFields fld, crRe.customerID.Font.Name, crRe.customerID.Font.Size, False, crRe.customerID.Height, crRe.customerID.Width, crRe.customerID.HorAlignment
Set fld = crRe.Sections(3).AddFieldObject("{ADO.customerName}", crRe.customerName.Left, crRe.customerName.Top)
SetFields fld, crRe.customerID.Font.Name, crRe.customerName.Font.Size, False, crRe.customerName.Height, crRe.customerName.Width, crRe.customerName.HorAlignment
Me.crCustomers.ReportSource = crRe
Me.crCustomers.ViewReport
Me.crCustomers.Zoom 75
End Sub
Private Sub SetFields(fld As FieldObject, fontName As String, fontSize As String, BoldStyle As Boolean, fieldHeight As Long, fieldWidth As Long, align As Long)
On Error GoTo bayloi
fld.Font = fontName
fld.TextFormat = crStandardText
fld.Font.Size = fontSize
fld.Font.Bold = BoldStyle
fld.Font.Italic = False
fld.TextColor = RGB(0, 0, 0)
fld.Height = fieldHeight
fld.Width = fieldWidth
fld.HorAlignment = align
Exit Sub
bayloi:
MsgBox "Err :" & Err.Number & vbNewLine & "Description :" & Err.Description & vbNewLine & "Source :" & Err.Source, vbInformation, "Error"
End Sub
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
|