|
-
Aug 26th, 2007, 09:36 PM
#1
Thread Starter
New Member
Crystal Report ask for logon info
Hi there:
I really need help in the following situation:
I develop an application using vb 2005 that uses an acces database. The application have an option to display reports, for the reports I use Crystal Reports (the one tha cames with vs 2005 professional). The acces database is password protected. The thing is tha everything works fine on my pc, but when I installed the application on another pc the report ask for logon. All other acces to the database works fine, excepts for the reports that keep waiting for logon info.
Thanks!
-
Sep 3rd, 2007, 06:07 PM
#2
New Member
Re: Crystal Report ask for logon info
Use this code to load the report...
Code:
Try
Dim crtableLogoninfos As New TableLogOnInfos()
Dim crtableLogoninfo As New TableLogOnInfo()
Dim crConnectionInfo As New ConnectionInfo()
Dim CrTables As Tables
Dim CrTable As Table
Dim crReportDocument As New G1()
With crConnectionInfo
.DatabaseName = Application.StartupPath & "\db.mdb"
.Password = "ps1"
End With
CrTables = crReportDocument.Database.Tables
For Each CrTable In CrTables
crtableLogoninfo = CrTable.LogOnInfo
crtableLogoninfo.ConnectionInfo = crConnectionInfo
CrTable.ApplyLogOnInfo(crtableLogoninfo)
Next
CRV.ReportSource = crReportDocument
Catch ex As Exception
MsgBox(ex.Message)
Me.Cursor = Cursors.Default
End Try
Note:
1- Don't forget to import the labraries
Code:
Imports CrystalDecisions.Shared
Imports CrystalDecisions.CrystalReports.Engine
2- G1 = the report document you create within Visual Studio
3- db.mdb = your database filename
4- ps1 = databse password
5- CRV = CrystalReportViewer control you add to the form
-
Sep 9th, 2007, 09:06 AM
#3
Thread Starter
New Member
Re: Crystal Report ask for logon info
Thank you for youre respomd. It really helps me in this situation. My problem is solved!. Thank you very much.
-
Sep 19th, 2007, 02:06 PM
#4
New Member
Re: Crystal Report ask for logon info
I am having a similar problem (VB.NET 2002, MS Access, and whatever version of CR came with VS.NET 2002) except my database is not password protected at all. It is based off of a dataset in the project and is running on my local machine. I initially was trying to call a Crystal Report Viewer on a seperate form and each time it prompted me for the database logon (which does not exist) so I tried using a Crystal Report Viewer on the main form and ran into the same problem. I tried using the code you posted, as well as some other examples I found online and it still prompted me for the login.
Also I should mention that I have been able to get it to work if I base a report off of OLE DB[ADO DB] in the database expert but that will not suit the needs of the application, I need to base it off of a dataset that is generated at run time when the user searches for a particular record. When I choose the appropriate dataset in project data it leads to the problem described above.
I really do not know how to proceed further, any advice would be apprecited.
-
Sep 19th, 2007, 02:06 PM
#5
New Member
Re: Crystal Report ask for logon info
sorry about the extra post...
-
Oct 8th, 2007, 11:15 PM
#6
New Member
Re: Crystal Report ask for logon info
I am having the same problem. except I can open one db file, and not another. same connect statement except for db name. Odd thing is, it works fine on my dev pc, but not at work. Also, at work, access gave me a message stating that it would not open it across on a network drive and advised I put it local. I did that and still same error.
Can anyone offer any suggestions ?
-
Oct 16th, 2007, 02:28 AM
#7
PowerPoster
Re: Crystal Report ask for logon info
I have the same problem as in Post 1 with vb6. Someone please drop me some code.
-
Oct 16th, 2007, 05:45 AM
#8
Re: Crystal Report ask for logon info
I use the following and it works just fine. I think its time you upgrade access to sql server 2005 express.
Code:
Dim crReportDocument As New tempos2
''crConnectionInfo = New ConnectionInfo
''With crConnectionInfo
'' .ServerName = "Dinefer"
'' .DatabaseName = "Dinefer"
'' .UserID = "Utilizador"
'' .Password = "ab,cdef123!"
''End With
''crDatabase = crReportDocument.Database
''crTables = crDatabase.Tables
''For Each crTable In crTables
'' crTableLogOnInfo = crTable.LogOnInfo
'' crTableLogOnInfo.ConnectionInfo = crConnectionInfo
'' crTable.ApplyLogOnInfo(crTableLogOnInfo)
''Next
Dim con As New SqlClient.SqlConnection
Dim com As New SqlClient.SqlCommand
Dim sqlapa As New SqlClient.SqlDataAdapter
Dim ds As DataSet
ds = New Dataset2
con.ConnectionString = constring
con.Open()
com.Connection = con
com.CommandType = CommandType.Text
com.CommandText = "select ponto.movimento,ponto.Inicio, ponto.Fim,ponto.delta,ponto.deltah,horarios.nome,tabt.ID, tabt.Nome NomeTrab from ponto,horarios,tabt where ponto.tipo = horarios.id and ponto.Trabalhador = tabt.ID"
sqlapa.SelectCommand = com
sqlapa.Fill(ds, "teste")
MessageBox.Show(ds.Tables("teste").Rows.Count.ToString)
formula = ""
crReportDocument.RecordSelectionFormula = formula
CrystalReportViewer1.DisplayGroupTree = False
CrystalReportViewer1.Zoom(100)
crReportDocument.SetDataSource(ds.Tables("teste"))
CrystalReportViewer1.ReportSource = crReportDocument
con.Close()
"The dark side clouds everything. Impossible to see the future is."
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
|