Click here to Skip to main content
15,885,933 members
Please Sign up or sign in to vote.
2.25/5 (3 votes)
See more:
I have a database without any username & password
but while runtime crystal report prompt enter username & password..
Posted
Comments
Animesh Datta 14-Dec-13 1:53am    
provide some code ,so that we can find your error .
jackspero18 14-Dec-13 2:01am    
no any error...bro
when crystal load data its prompting login,
but to my database i din't gave any authentication
Animesh Datta 14-Dec-13 2:08am    
I think you Set the datasource property of Crystal report to a dataset directly . instead of that you bind the datasource to a datatable .
jackspero18 14-Dec-13 2:10am    
may b can u please provide me any source...
Shanti Lal Namchuriya 9-Dec-14 2:58am    
eassy and simple solution for all ....
open field explorer---> database field --->Right Click -->current Data source --->reports connection----->report ----->property ----> set Property as---

Data Source: .\Databasename.accdb

and code on viewer form load as

Dim cryRpt As New ReportDocument

Dim Report1 As New rptItemWise

Dim strServerName As String
strServerName = Application.StartupPath
rptItemWise.SetDatabaseLogon("admin", "", strServerName, "dastabasename.accdb", True)



cryRpt.Load(Application.StartupPath + "\rptItemWise.rpt")

also change the report connection same as data source i think that code work for you ..

You need to apply the logon details at runtime, check it out
C# Crystal Reports Dynamic Logon parameters[^]

EDIT
-------------
SAP Crystal Report using SQL Server Authentication and Windows Authentication[^]
 
Share this answer
 
v2
Comments
jackspero18 14-Dec-13 2:28am    
crConnectionInfo.ServerName = "YOUR SERVER NAME";
crConnectionInfo.DatabaseName = "YOUR DATABASE NAME";
crConnectionInfo.UserID = "YOUR DATABASE USERNAME";
crConnectionInfo.Password = "YOUR DATABASE PASSWORD";

no userid n password given to my database while creating so wat to replace
thatraja 14-Dec-13 2:40am    
Check updated answer
Hello ,
Try this

CrystalReport cr = new CrystalReport();
--call the crystall report

DataSet ds1 = new DataSet();
SqlConnection myCon;
SqlDataAdapter myAdapter;

myCon = new SqlConnection("Data Source=.;Initial Catalog=dbs;
Persist Security Info=True;");

SqlCommand cmd = new SqlCommand("select * from tbl", myCon);

myAdapter = new SqlDataAdapter(cmd);
myAdapter.Fill(ds1);
-- Fill the dataset
if (ds1.Tables[0].Rows.Count > 0)
{

    cr.SetDataSource(ds1.Tables[0]);
   --here set the crytal report DataSource to  DataTable
    crystalReportViewer1.ReportSource = cr;
    crystalReportViewer1.Refresh();
}


thanks
 
Share this answer
 
Comments
jackspero18 14-Dec-13 2:35am    
ERROR

Could not load file or assembly 'file:///C:\Program Files\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86\dotnet1\crdb_adoplus.dll' or one of its dependencies. The system cannot find the file specified.
Animesh Datta 14-Dec-13 2:41am    
What crystal report version you are using in your project ? This is for VS 2010 , Crystal report version CRforVS_13_0_2
jackspero18 14-Dec-13 2:58am    
which version should i use
jackspero18 14-Dec-13 3:03am    
& i am using visual studio 2010
Animesh Datta 14-Dec-13 3:05am    
If you are using VS2010 then download SAP Crystal report from this link
[http://downloads.businessobjects.com/akdlm/cr4vs2010/CRforVS_13_0_2.exe]
eassy and simple solution for all ....
open field explorer---> database field --->Right Click -->current Data source --->reports connection----->report ----->property ----> set Property as---

Data Source: .\Databasename.accdb

and code on viewer form load as

Dim cryRpt As New ReportDocument

Dim Report1 As New rptItemWise

Dim strServerName As String
strServerName = Application.StartupPath
rptItemWise.SetDatabaseLogon("admin", "", strServerName, "dastabasename.accdb", True)



cryRpt.Load(Application.StartupPath + "\rptItemWise.rpt")

also change the report connection same as data source i think that code work for you ..
 
Share this answer
 
Remove tick mark -> Verify on every print...from Crystal Report...Right click to database field
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900