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. . . .
Printable View
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. . . .
First you have to importing the folowing namespaces up to the Public Class FormX:
In the form load event of the form which contains the crystal report viewer type the folowing code:Code:Imports CrystalDecisions.Shared
Imports CrystalDecisions.CrystalReports
Imports CrystalDecisions.CrystalReports.Engine
Good luck :)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()
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. . . .
No, the same connection info variables but with your won server data values:
Good luckCode:Dim ServerName As String = "Localhost"
Dim UserID As String = "root"
Dim Password As String = ""
Dim DatabaseName As String = "YourDatabaseName"
I try the code and it the same it asked for the database login. . . .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 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:
Good luckCode: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)
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
Thread moved from the 'VB.Net' forum to the 'Reporting' forum (thanks for letting us know dbasnett :thumb: )
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??
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)
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.
These, UserID, Password, ServerName, DatabaseName, are variables. You have to assign them values.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
If you search this forum or Google for "crystal reports login" you should find lots of examples.