Results 1 to 13 of 13

Thread: Problem with crytal report. . . .I

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2011
    Posts
    137

    Problem with crytal report. . . .I

    Problem in crystal report Database login how can i solve this??Asking me 4 the Login ID and password. . . .anyone please elp me with this. . . .

  2. #2
    Addicted Member Programmation's Avatar
    Join Date
    Nov 2009
    Posts
    161

    Re: Problem with crytal report. . . .I

    First you have to importing the folowing namespaces up to the Public Class FormX:

    Code:
    Imports CrystalDecisions.Shared
    Imports CrystalDecisions.CrystalReports
    Imports CrystalDecisions.CrystalReports.Engine
    In the form load event of the form which contains the crystal report viewer type the folowing code:

    Code:
    Dim MyReport As New MyReportName
            Dim ServerName As String = "MyDataSource"
            Dim UserID As String = "MyUserID"
            Dim Password As String = "MyUserPassword"
            Dim DatabaseName As String = "MyDataBaseName"
            Dim rptTable As CrystalDecisions.CrystalReports.Engine.Table
            Dim rptLogIn As TableLogOnInfo = New CrystalDecisions.Shared.TableLogOnInfo
            MyReport.SetDatabaseLogon(UserID, Password, ServerName, DatabaseName)
            For Each rptTable In MyReport.Database.Tables
                rptLogIn = rptTable.LogOnInfo
                rptLogIn.ConnectionInfo.ServerName = ServerName
                rptLogIn.ConnectionInfo.DatabaseName = DatabaseName
                rptLogIn.ConnectionInfo.UserID = UserID
                rptLogIn.ConnectionInfo.Password = Password
                rptTable.ApplyLogOnInfo(rptLogIn)
            Next
            MyReport.Refresh()
            MyCrystalReportViewer.ReportSource = MyReport
            MyCrystalReportViewer.Show()
    Good luck
    Just Do It!

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2011
    Posts
    137

    Re: Problem with crytal report. . . .I

    Im using mysql xampp and the default is server localhost, uid=root, pwd=nothing, and my database is details is this what will i put in this??. . . .
    What will i put in the rptLogIn.ConnectionInfo.ServerName = ServerName
    rptLogIn.ConnectionInfo.DatabaseName = DatabaseName
    rptLogIn.ConnectionInfo.UserID = UserID
    rptLogIn.ConnectionInfo.Password = Password
    ??or should i declare the variables and assign my server uid etc. . . .

  4. #4
    Addicted Member Programmation's Avatar
    Join Date
    Nov 2009
    Posts
    161

    Re: Problem with crytal report. . . .I

    No, the same connection info variables but with your won server data values:

    Code:
    Dim ServerName As String = "Localhost"
    Dim UserID As String = "root"
    Dim Password As String = ""
    Dim DatabaseName As String = "YourDatabaseName"
    Good luck
    Just Do It!

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Mar 2011
    Posts
    137

    Re: Problem with crytal report. . . .

    Code:
    Dim MyReport As New crreceipt 'This is my crystalreport
            Dim ServerName As String = "localhost" 'server name
            Dim UserID As String = "root" 'userid
            Dim Password As String = "" 'my password
            Dim DatabaseName As String = "employee_info" 'and the name of my database
            Dim rptTable As CrystalDecisions.CrystalReports.Engine.Table
            Dim rptLogIn As TableLogOnInfo = New CrystalDecisions.Shared.TableLogOnInfo
            MyReport.SetDatabaseLogon(UserID, Password, ServerName, DatabaseName)
            For Each rptTable In MyReport.Database.Tables
                rptLogIn = rptTable.LogOnInfo
                rptLogIn.ConnectionInfo.ServerName = ServerName
                rptLogIn.ConnectionInfo.DatabaseName = DatabaseName
                rptLogIn.ConnectionInfo.UserID = UserID
                rptLogIn.ConnectionInfo.Password = Password
                rptTable.ApplyLogOnInfo(rptLogIn)
            Next
            MyReport.Refresh()
            MyCrystalReportViewer.ReportSource = MyReport
            MyCrystalReportViewer.Show()
    I try the code and it the same it asked for the database login. . . .
    i follow the instruction properly is their something missing in the code??

    this is my code in the other form I put this in the click event. . . .

    Code:
    Dim rptForm As New CrystalDecisions.CrystalReports.Engine.ReportDocument
            Dim rpt As New crreceipt()
            Dim T1, T2, T3, T4, T5, T6, T7 As CrystalDecisions.CrystalReports.Engine.TextObject
            rpt.SetDataSource(dt)
            rptForm = rpt    'rpt is your report object
            T1 = rptForm.ReportDefinition.Sections(0).ReportObjects("T1")
            T2 = rptForm.ReportDefinition.Sections(0).ReportObjects("T2")
            T3 = rptForm.ReportDefinition.Sections(0).ReportObjects("T3")
            T4 = rptForm.ReportDefinition.Sections(0).ReportObjects("T4")
            T5 = rptForm.ReportDefinition.Sections(0).ReportObjects("T5")
            T6 = rptForm.ReportDefinition.Sections(0).ReportObjects("T6")
            T7 = rptForm.ReportDefinition.Sections(0).ReportObjects("T7")
            T1.Text = lblcashier.Text
            T2.Text = txtinv.Text
            T3.Text = lbldate.Text
            T4.Text = lbltime.Text
            T5.Text = grandtotal.Text
            T6.Text = txttendered.Text
            T7.Text = txtmoney.Text
            frmreceipt.CrystalReportViewer1.ReportSource = rpt
            frmreceipt.Show()
            frmreceipt.CrystalReportViewer1.Zoom(90)
    Last edited by sukarno1234; Oct 18th, 2011 at 11:47 PM.

  6. #6
    Addicted Member Programmation's Avatar
    Join Date
    Nov 2009
    Posts
    161

    Re: Problem with crytal report. . . .

    Quote Originally Posted by sukarno1234 View Post
    Code:
    Dim MyReport As New crreceipt 'This is my crystalreport
            Dim ServerName As String = "localhost" 'server name
            Dim UserID As String = "root" 'userid
            Dim Password As String = "" 'my password
            Dim DatabaseName As String = "employee_info" 'and the name of my database
            Dim rptTable As CrystalDecisions.CrystalReports.Engine.Table
            Dim rptLogIn As TableLogOnInfo = New CrystalDecisions.Shared.TableLogOnInfo
            MyReport.SetDatabaseLogon(UserID, Password, ServerName, DatabaseName)
            For Each rptTable In MyReport.Database.Tables
                rptLogIn = rptTable.LogOnInfo
                rptLogIn.ConnectionInfo.ServerName = ServerName
                rptLogIn.ConnectionInfo.DatabaseName = DatabaseName
                rptLogIn.ConnectionInfo.UserID = UserID
                rptLogIn.ConnectionInfo.Password = Password
                rptTable.ApplyLogOnInfo(rptLogIn)
            Next
            MyReport.Refresh()
            MyCrystalReportViewer.ReportSource = MyReport
            MyCrystalReportViewer.Show()
    I try the code and it the same it asked for the database login. . . .
    i follow the instruction properly is their something missing in the code??

    this is my code in the other form I put this in the click event. . . .

    Code:
    Dim rptForm As New CrystalDecisions.CrystalReports.Engine.ReportDocument
            Dim rpt As New crreceipt()
            Dim T1, T2, T3, T4, T5, T6, T7 As CrystalDecisions.CrystalReports.Engine.TextObject
            rpt.SetDataSource(dt)
            rptForm = rpt    'rpt is your report object
            T1 = rptForm.ReportDefinition.Sections(0).ReportObjects("T1")
            T2 = rptForm.ReportDefinition.Sections(0).ReportObjects("T2")
            T3 = rptForm.ReportDefinition.Sections(0).ReportObjects("T3")
            T4 = rptForm.ReportDefinition.Sections(0).ReportObjects("T4")
            T5 = rptForm.ReportDefinition.Sections(0).ReportObjects("T5")
            T6 = rptForm.ReportDefinition.Sections(0).ReportObjects("T6")
            T7 = rptForm.ReportDefinition.Sections(0).ReportObjects("T7")
            T1.Text = lblcashier.Text
            T2.Text = txtinv.Text
            T3.Text = lbldate.Text
            T4.Text = lbltime.Text
            T5.Text = grandtotal.Text
            T6.Text = txttendered.Text
            T7.Text = txtmoney.Text
            frmreceipt.CrystalReportViewer1.ReportSource = rpt
            frmreceipt.Show()
            frmreceipt.CrystalReportViewer1.Zoom(90)
    Your Code:

    Code:
    Dim MyReport As New crreceipt 'This is my crystalreport
            Dim ServerName As String = "localhost" 'server name
            Dim UserID As String = "root"
            Dim Password As String = "" 'my password
            Dim DatabaseName As String = "employee_info" 'and the name of my database
            Dim rptTable As CrystalDecisions.CrystalReports.Engine.Table
            Dim rptLogIn As TableLogOnInfo = New CrystalDecisions.Shared.TableLogOnInfo
            Dim T1, T2, T3, T4, T5, T6, T7 As CrystalDecisions.CrystalReports.Engine.TextObject
            '=============================================================
            T1 = crreceipt.ReportDefinition.Sections(0).ReportObjects("T1")
            T2 = crreceipt.ReportDefinition.Sections(0).ReportObjects("T2")
            T3 = crreceipt.ReportDefinition.Sections(0).ReportObjects("T3")
            T4 = crreceipt.ReportDefinition.Sections(0).ReportObjects("T4")
            T5 = crreceipt.ReportDefinition.Sections(0).ReportObjects("T5")
            T6 = crreceipt.ReportDefinition.Sections(0).ReportObjects("T6")
            T7 = crreceipt.ReportDefinition.Sections(0).ReportObjects("T7")
            '=============================================================
            crreceipt.SetDatabaseLogon(UserID, Password, ServerName, DatabaseName)
            For Each rptTable In crreceipt.Database.Tables
                rptLogIn = rptTable.LogOnInfo
                rptLogIn.ConnectionInfo.ServerName = ServerName
                rptLogIn.ConnectionInfo.DatabaseName = DatabaseName
                rptLogIn.ConnectionInfo.UserID = UserID
                rptLogIn.ConnectionInfo.IntegratedSecurity = True
                rptTable.ApplyLogOnInfo(rptLogIn)
            Next
            crreceipt.SetDataSource(dt)
            '=============================================================
            T1.Text = lblcashier.Text
            T2.Text = txtinv.Text
            T3.Text = lbldate.Text
            T4.Text = lbltime.Text
            T5.Text = grandtotal.Text
            T6.Text = txttendered.Text
            T7.Text = txtmoney.Text
            '=============================================================
            crreceipt.Refresh()
            frmreceipt.CrystalReportViewer1.ReportSource = crreceipt
            frmreceipt.Show()
            frmreceipt.CrystalReportViewer1.Zoom(90)
    Good luck
    Just Do It!

  7. #7
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: Problem with crytal report. . . .I

    There is a section of the forum dedicated to reporting. Maybe you should ask your question there.

    http://www.vbforums.com/forumdisplay.php?f=33
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  8. #8
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Problem with crytal report. . . .I

    Thread moved from the 'VB.Net' forum to the 'Reporting' forum (thanks for letting us know dbasnett )

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Mar 2011
    Posts
    137

    Re: Problem with crytal report. . . .

    Quote Originally Posted by Programmation View Post
    Your Code:

    Code:
    Dim MyReport As New crreceipt 'This is my crystalreport
            Dim ServerName As String = "localhost" 'server name
            Dim UserID As String = "root"
            Dim Password As String = "" 'my password
            Dim DatabaseName As String = "employee_info" 'and the name of my database
            Dim rptTable As CrystalDecisions.CrystalReports.Engine.Table
            Dim rptLogIn As TableLogOnInfo = New CrystalDecisions.Shared.TableLogOnInfo
            Dim T1, T2, T3, T4, T5, T6, T7 As CrystalDecisions.CrystalReports.Engine.TextObject
            '=============================================================
            T1 = crreceipt.ReportDefinition.Sections(0).ReportObjects("T1")
            T2 = crreceipt.ReportDefinition.Sections(0).ReportObjects("T2")
            T3 = crreceipt.ReportDefinition.Sections(0).ReportObjects("T3")
            T4 = crreceipt.ReportDefinition.Sections(0).ReportObjects("T4")
            T5 = crreceipt.ReportDefinition.Sections(0).ReportObjects("T5")
            T6 = crreceipt.ReportDefinition.Sections(0).ReportObjects("T6")
            T7 = crreceipt.ReportDefinition.Sections(0).ReportObjects("T7")
            '=============================================================
            crreceipt.SetDatabaseLogon(UserID, Password, ServerName, DatabaseName)
            For Each rptTable In crreceipt.Database.Tables
                rptLogIn = rptTable.LogOnInfo
                rptLogIn.ConnectionInfo.ServerName = ServerName
                rptLogIn.ConnectionInfo.DatabaseName = DatabaseName
                rptLogIn.ConnectionInfo.UserID = UserID
                rptLogIn.ConnectionInfo.IntegratedSecurity = True
                rptTable.ApplyLogOnInfo(rptLogIn)
            Next
            crreceipt.SetDataSource(dt)
            '=============================================================
            T1.Text = lblcashier.Text
            T2.Text = txtinv.Text
            T3.Text = lbldate.Text
            T4.Text = lbltime.Text
            T5.Text = grandtotal.Text
            T6.Text = txttendered.Text
            T7.Text = txtmoney.Text
            '=============================================================
            crreceipt.Refresh()
            frmreceipt.CrystalReportViewer1.ReportSource = crreceipt
            frmreceipt.Show()
            frmreceipt.CrystalReportViewer1.Zoom(90)
    Good luck
    i tried the code but it asking the database login.I tried putting the code in the click event which is in another form, also in the form load event which contains the crystal viewer. . . .I replace crreceipt with MyReport thats my crreceipt and also i have a reportdocument which is rptform. . . .any ideas what is wrong with the code??

  10. #10
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,517

    Re: Problem with crytal report. . . .I

    You should post your code.

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Mar 2011
    Posts
    137

    Re: Problem with crytal report. . . .I

    Quote Originally Posted by wes4dbt View Post
    You should post your code.
    This is my code. . . .

    Code:
    Dim rptForm As New CrystalDecisions.CrystalReports.Engine.ReportDocument
            Dim rpt As New crreceipt()
            Dim T1, T2, T3, T4, T5, T6, T7 As CrystalDecisions.CrystalReports.Engine.TextObject
            rpt.SetDataSource(dt)
            rptForm = rpt    'rpt is your report object
            T1 = rptForm.ReportDefinition.Sections(0).ReportObjects("T1")
            T2 = rptForm.ReportDefinition.Sections(0).ReportObjects("T2")
            T3 = rptForm.ReportDefinition.Sections(0).ReportObjects("T3")
            T4 = rptForm.ReportDefinition.Sections(0).ReportObjects("T4")
            T5 = rptForm.ReportDefinition.Sections(0).ReportObjects("T5")
            T6 = rptForm.ReportDefinition.Sections(0).ReportObjects("T6")
            T7 = rptForm.ReportDefinition.Sections(0).ReportObjects("T7")
            T1.Text = lblcashier.Text
            T2.Text = txtinv.Text
            T3.Text = lbldate.Text
            T4.Text = lbltime.Text
            T5.Text = grandtotal.Text
            T6.Text = txttendered.Text
            T7.Text = txtmoney.Text
            frmreceipt.CrystalReportViewer1.ReportSource = rpt
            frmreceipt.Show()
            frmreceipt.CrystalReportViewer1.Zoom(90)

  12. #12
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,517

    Re: Problem with crytal report. . . .I

    The code posted by programmation is just and example. You need to modify it to match your report.

    You left out the most important part, the login information.
    Code:
            crreceipt.SetDatabaseLogon(UserID, Password, ServerName, DatabaseName)
            For Each rptTable In crreceipt.Database.Tables
                rptLogIn = rptTable.LogOnInfo
                rptLogIn.ConnectionInfo.ServerName = ServerName
                rptLogIn.ConnectionInfo.DatabaseName = DatabaseName
                rptLogIn.ConnectionInfo.UserID = UserID
                rptLogIn.ConnectionInfo.IntegratedSecurity = True
                rptTable.ApplyLogOnInfo(rptLogIn)
            Next
    These, UserID, Password, ServerName, DatabaseName, are variables. You have to assign them values.

    If you search this forum or Google for "crystal reports login" you should find lots of examples.

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    Mar 2011
    Posts
    137

    Re: Problem with crytal report. . . .I

    Quote Originally Posted by wes4dbt View Post
    The code posted by programmation is just and example. You need to modify it to match your report.

    You left out the most important part, the login information.
    Code:
            crreceipt.SetDatabaseLogon(UserID, Password, ServerName, DatabaseName)
            For Each rptTable In crreceipt.Database.Tables
                rptLogIn = rptTable.LogOnInfo
                rptLogIn.ConnectionInfo.ServerName = ServerName
                rptLogIn.ConnectionInfo.DatabaseName = DatabaseName
                rptLogIn.ConnectionInfo.UserID = UserID
                rptLogIn.ConnectionInfo.IntegratedSecurity = True
                rptTable.ApplyLogOnInfo(rptLogIn)
            Next
    These, UserID, Password, ServerName, DatabaseName, are variables. You have to assign them values.

    If you search this forum or Google for "crystal reports login" you should find lots of examples.
    i laready use this code but the result is the same. I put my code in the form where the crystal viewer is located but it gives me the same result asking me 4 the database login. and i also tried it in my click event 2 i use Mysql xampp for my database. . . .

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