Results 1 to 3 of 3

Thread: New To Cystal Reports

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2006
    Posts
    17

    Lightbulb 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

  2. #2
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Re: New To Cystal Reports

    you are going to have to make a ODBC connection to your SQL database.

  3. #3
    Member
    Join Date
    Jan 2006
    Posts
    32

    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
  •  



Click Here to Expand Forum to Full Width