In this article I am going to discuss how to use UDL file
with Crystal Report to connect particular database.
Using the code
What is UDL?
Universal Data Link
files (.udl files) can be used to store information of connection string. So it
works as a common user interface for specifying connection attributes.
How to create a UDL
- Open a
notepad and save it using .udl extension. (Note: don not write anything in
that notepad). 2. Now it
displays with small computer icon.
you should configure your udl file. Double click on the udl file. Now it
displays as follows.
select a provider. In this example I have used Microsoft SQL server 2005
express edition. So I need to use Microsoft
OLE DB Provider for SQL Server as the provider. Then click Next button or Connection tab.
you will have to select details which related to SQL server. After
providing those data, you can check connection is success or not by
clicking Test Connection button.
Now you can add crystal report to your project. Select OLE DB (ADO) as the data source of the
Then display OLE DB (ADO) dialog box. Now select use data
link file and browse your .udl file.
After configuring data source, you can add SQL query to
crystal report by double clicking AddCommand. Now you can SQL query here.
After creating crystal report you can display it on your
asp.net web page. For that you have to add CrystalReportViwer control to your
web page. After then write following code in the code behind page.
public partial class _Default : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
doc = new ReportDocument();
CrystalReportViewer1.ReportSource = doc;
catch (Exception ex)
Label1.Text = ex.Message;
Points of Interest
You can use the for windows based application development also.