|
-
Oct 18th, 2011, 10:46 AM
#1
Thread Starter
Addicted Member
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. . . .
-
Oct 18th, 2011, 11:32 AM
#2
Addicted Member
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
-
Oct 18th, 2011, 12:07 PM
#3
Thread Starter
Addicted Member
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. . . .
-
Oct 18th, 2011, 12:11 PM
#4
Addicted Member
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
-
Oct 18th, 2011, 11:43 PM
#5
Thread Starter
Addicted Member
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.
-
Oct 19th, 2011, 06:53 AM
#6
Addicted Member
Re: Problem with crytal report. . . .
 Originally Posted by sukarno1234
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
-
Oct 19th, 2011, 07:06 AM
#7
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
-
Oct 19th, 2011, 07:11 AM
#8
Re: Problem with crytal report. . . .I
Thread moved from the 'VB.Net' forum to the 'Reporting' forum (thanks for letting us know dbasnett )
-
Oct 22nd, 2011, 09:14 AM
#9
Thread Starter
Addicted Member
Re: Problem with crytal report. . . .
 Originally Posted by Programmation
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??
-
Oct 22nd, 2011, 11:24 AM
#10
Re: Problem with crytal report. . . .I
You should post your code.
-
Oct 22nd, 2011, 04:47 PM
#11
Thread Starter
Addicted Member
Re: Problem with crytal report. . . .I
 Originally Posted by wes4dbt
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)
-
Oct 22nd, 2011, 09:11 PM
#12
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.
-
Oct 23rd, 2011, 05:44 AM
#13
Thread Starter
Addicted Member
Re: Problem with crytal report. . . .I
 Originally Posted by wes4dbt
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|