Hi i am trying to create a crystal report using C# coding but instead of creating a web application under new project i decided to choose create an asp.net website with C#. The problem is i get:-
The report you requested requires further information.
--------------------------------------------------------------------------------
XP\SQLEXPRESS
Server name:
Database name:
User name:
Password:
All data is present except my password when i enter it, it works fine and the report works too with no problems. How do i remove this prompt. There is a property called "DatabaseLogonPrompt" but if i set it to false. The report will no show up telling me the parameters are incorrect. So the password has to be entered in the code but where i dont know.Build the report method:
The crystal report i built in this manner.
1) Added Crystal Report from add new item
2) Followed the instructions
3) Chose to create a new connection
4) OLE DB
5) OLEDB provider for SQL Server
6) Input servername,id, password and database name from combothis created the report
I installed IIS on my local pc having win xp sp2. Also have Sql express 2005 on the same machine.
So i need to find a way to remove the prompt. Found codes but it was either windows applicaiton with C# or web application in vb. I want code for C# web application or website in C#. I relatively new to ASP.net as i finished my .net at the end of last month
Please HELP!!!
Hey guys please Help Me :(
![]() |
0 |
![]() |
I'm afraid I don't know C# syntax, so I can't tell you exactly how to do it. But here's an example in VB that shouldn't be all that different from what you want (just translate the syntax to C#):
If (Session("forepipeq4") Is Nothing) Then forepipeq4 = New ReportDocument() 'load the report document forepipeq4.Load("D:\IIS Web Roots\Crystal\reports\Fore-Pipe-Q4\Fore_Pipe-Q4.rpt") 'web server 'forepipeq4.Load("C:/Documents and Settings/cfry/Desktop/Web_Reports/Fore-Pipe-Q4/Fore_Pipe-Q4.rpt") 'local 'authenticate to the database reportDB = forepipeq4.Database 'get the database reportTables = reportDB.Tables 'get the tables 'iterate through all of the tables, setting the correct login information for all of them For Each reportTable In reportTables reportLogOnInfo = reportTable.LogOnInfo 'get the LogOnInfo object 'reportLogOnInfo.ConnectionInfo.ServerName = "server" 'specify the server 'reportLogOnInfo.ConnectionInfo.DatabaseName = "database" 'specify the database 'reportLogOnInfo.ConnectionInfo.UserID = "username" 'specify the user name reportLogOnInfo.ConnectionInfo.Password = "password" 'specify the password reportTable.ApplyLogOnInfo(reportLogOnInfo) 'save the changes Next reportTable
For security reasons, Crystal will -not- store the password with the Report, so you must set that. I have the other lines in there (for database, username, etc.), should I want to set the other pieces of the authentication information, but they are commented out because they weren't necessary for me in this case. A couple of other things to be aware of: if you are planning to deploy your report to a different machine than the one you are creating it on, expect to have some trouble (it's a pain...). Make sure that any ODBC connection you use when creating the report is replicated -identically- on the server you deploy to because Crystal stores the name, etc. and will start doing weird things if circumstances aren't the same. Well, that's getting a bit off-topic, but hope this helps with the authentication part at least....
Pont
![]() |
1 |
![]() |
The code may work with vb but desperately need C# language
Hey guys please Help Me :(
![]() |
0 |
![]() |
Hello please help
Hey guys please Help Me :(
![]() |
0 |
![]() |
Use this code, Hope it resolves ur issue...
Here is the code for that in VB.NET:
##############################
On the page load or button click or whatever you want to run the report on you need to add the following: configureCRYSTALREPORT()
Private Sub configureCRYSTALREPORT()
Dim myConnectionInfo As New ConnectionInfo()
myConnectionInfo.DatabaseName = "DatabserName"
myConnectionInfo.UserID = "UID"
myConnectionInfo.Password = "PWD"
setDBLOGONforREPORT(myConnectionInfo)
End Sub
Private Sub setDBLOGONforREPORT(ByVal myconnectioninfo As ConnectionInfo)
Dim mytableloginfos As New TableLogOnInfos()
mytableloginfos = CrystalReportViewer1.LogOnInfo
For Each myTableLogOnInfo As TableLogOnInfo In mytableloginfos
myTableLogOnInfo.ConnectionInfo = myconnectioninfo
Next
End Sub
-------------------------------------------------------------------------------------------------------------------------------------------------
Here is the code for that in C#:
##########################
private void setDBLOGONforREPORT(ConnectionInfo myconnectioninfo)
{
TableLogOnInfos mytableloginfos = new TableLogOnInfos();
mytableloginfos = CrystalReportViewer1.LogOnInfo;
foreach (TableLogOnInfo myTableLogOnInfo in mytableloginfos)
{
myTableLogOnInfo.ConnectionInfo = myconnectioninfo;
}
}
In Page Load....
ConnectionInfo myConnectionInfo = new ConnectionInfo();
myConnectionInfo.ServerName = "serverName";
myConnectionInfo.DatabaseName = "DatabaseName";
myConnectionInfo.UserID = "sa";
myConnectionInfo.Password = "pwd";
setDBLOGONforREPORT(myConnectionInfo);
Thanks!!
Jagadeesh
Don’t forget to 'mark this as answer' if this post helps you.
www.mReach.Net ...for Online Live TV Channels, Radio's and WebCams Live
Online Live TV Channels, Radio's and WebCams
![]() |
0 |
![]() |