Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
How to connect to Database file in App_Data folder in ASP.Net for Crystal Reports Database Fields ???

I have made a web project. In that, right clicked the website name in the solution explorer. Then chose add new item - SQL Database. Then a database file named Database.mdf was added to the App_Data folder in the website.

This is the database that I use in the project for each and every information.
On one page, I want to generate a report so as to facilitate printing that info. For this, I have added a crystal report to the website. The report takes one parameter i.e. id. Based on that, the other data in the database's table will be displayed in the report. For this, first we have to select the Database expert to connect to a particular database so that the columns of the selected table are displayed in the Field Explorer of the Crystal Report.
But, I am not getting the way to connect to the Database.mdf file using the Database Expert......
Have selected the OLE DB provider for Sql Server, after that, I dont know what Server, Username, Password, Database name to write. The connection string of the local database file as mentioned in Web.config is:
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>



Tried using DataSet as DataSource. But, no fields are being displayed on putting condition on Id field to be equal to the parameter(id) passed to it.

Plzzzzzzzzzzz reply...... Project on stake!.......
Posted
Updated 28-Feb-11 5:20am
v6
Comments
Sunasara Imdadhusen 23-Feb-11 3:15am    
Not clear!!
Sandeep Mewara 23-Feb-11 4:11am    
When your project is at stake, find some time and post your issue properly
(only if you really want some resolution)!
Tech Code Freak 3-Mar-11 23:47pm    
I have modified the question in a detailed manner. Please have a look and guide me.... Thanks!......

1 solution

hiiiiiii
after adding crystal report from NEW ITEM,Choose Using the Report Wizard,Click OK. In next window
select CREATE NEW CONNECTION under that go to OLE DB(ADO),Then select Microsoft OLE DB Provider For SQL Server. Click next,Give your Connection Details and Choose your Database.Click next It will show u advance information window.Just press FINISH.Then choose your server ,click on that and choose your database and tables.after adding the table you can use it in your crystal report.
For parameter field you can create one parameter field and edit the query in crystal report....

GOOD LUCK
 
Share this answer
 
Comments
Davda Hiren 18-Sep-13 22:35pm    
I also have same problem. I created database using solution explorer in
vs2008. Now database is created as .mdf a local database . While in report we have to provide server name
And this file does not have server name . We have to browse it for connect there is no option
For thisprocess
Tech Code Freak 28-Feb-11 11:24am    
Thanks for the reply.

I have done the same thing but, I dont know what Server, Username, Password, Database name to write. The connection string of the local database file as mentioned in Web.config is:

<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
MosuliNodangala 20-Sep-12 0:27am    
Apparently your database.mdf file is on tha App_Folder. I have the same problem too. If someone can help, I need to connect a crystal report to a database.mdf that is on the App_Folder not Microsoft SQL Server.

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