Results 1 to 4 of 4

Thread: Change Location od database In SQL Server

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2003
    Location
    Bhutan
    Posts
    26

    Change Location od database In SQL Server

    How can Change the Location of Database of SQl Server 2000 in Crystal report or What can be the Path for SQL Server:
    For Instance , if database in mdb; I can change in following
    Databasetable.location=App.path & "\abcd.mdb"
    but for SQL Server=?????????
    Please help me!!!!!

  2. #2
    Addicted Member
    Join Date
    Mar 2002
    Location
    St. Louis MO
    Posts
    129
    SQL Server is different than Microsoft Access. In the SQL world, you work with a Database server instead of a database file on a drive somewhere, so the connecting is totally different.

    It goes something like this:


    Dim CRReport As New CRAXDRT.Report
    Dim CRApp As New CRAXDRT.Application
    Dim CRDBTable As CRAXDRT.DatabaseTable

    'Open the report file up
    Set CRReport = CRApp.OpenReport("Some RPT Filename goes here", 1)

    'Point all the tables in the report to look at whatever database we're interested in.
    'Note: this is only needed if you are using a different databases for development & testing and Production.

    For Each CRDBTable In CRReport.Database.Tables
    CRDBTable.SetLogOnInfo "Server Name goes here", "Database name on the server goes here", "Login Name for database goes here", "Login Password Goes here"
    Next

    'Point the Viewer control to the report and display it onscreen
    CRViewer1.ReportSource = CRReport
    CRViewer1.ViewReport


    Hope that helps.

  3. #3
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    In addition, if your report has any sub-reports you need to set the login information as well.

    If the database table or stored procedure names are different you might need to set the Table.Location property.

    This thread has a routine that might give you some ideas
    http://www.vbforums.com/showthread.p...readid=236776&

  4. #4

    Thread Starter
    Junior Member
    Join Date
    May 2003
    Location
    Bhutan
    Posts
    26

    Records Does not Changes!!!!!

    With your help I did but Record of field remains same..... and seems report is pointing to same database; Here is my code

    Private CrxApplication As New CRAXDRT.Application
    Public report As CRAXDRT.report

    Private Sub Form_Load()
    Dim CrxDatabasetable As CRAXDRT.DatabaseTable
    Dim CrxSubreport As CRAXDRT.report
    Dim Paths As String

    Paths = Mid(App.Path, 1, (Len(App.Path))) & "\report\bbe\"
    Set report = CrxApplication.OpenReport(Paths & "Reg1.rpt", 1)

    For Each CrxDatabasetable In report.Database.Tables
    CrxDatabasetable.SetLogOnInfo "SONAMG\ABC","2003, "sa", ""
    Next

    report.SelectPrinter "HP LaserJet 2200 Series PCL 6", "Duplicate", "DOT4_001"

    report.PrintOut True

    End Sub

    When I get print out it is found that rocords have be read from Database 2002.
    Or did I made mistake in some where else or left some Important code:

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