You open the UDL file with the notepad. There you can find the connection string, then you can copy the connection string to your web.config file and from there you can call the connection string and connect to your database using the connection object.
See the web.config files snippet,
<connectionStrings>
<add name="myConn" connectionString="String From your udl file"/>
</connectionStrings>
Now, in your application file (C#) you can call the connection string as follows,
Member
138 Points
722 Posts
how do i use a UDL file?
Jul 01, 2009 03:00 AM|young345|LINK
I have a udl file which I want to use so I can connect to the database.
I have written the code in the webconfig file so it will link to this udl file.
However, I don’t think that is enough, I think I have to write in the code somewhere that I want to use this UDL file.
I have never done this before, does anyone know how I can do this, is there some kind of techinique?
I am using c# and visual studio 2005.
Thank you
Contributor
2148 Points
645 Posts
Re: how do i use a UDL file?
Jul 01, 2009 05:50 AM|Ambran|LINK
Hi Y.
Found an old guide for using an UDL file for database access:
http://aspalliance.com/434_Database_Access_Using_UDL_Files.all
Hope this helps
Amit
Member
676 Points
257 Posts
Re: how do i use a UDL file?
Jul 01, 2009 06:11 AM|chandu2chandu1|LINK
You open the UDL file with the notepad. There you can find the connection string, then you can copy the connection string to your web.config file and from there you can call the connection string and connect to your database using the connection object. See the web.config files snippet,
Now, in your application file (C#) you can call the connection string as follows,
[Albert Einstein]
Regards,
Chandu
All-Star
25756 Points
7014 Posts
Re: how do i use a UDL file?
Jul 01, 2009 09:15 AM|hans_v|LINK
Why would you use a UDL? Just connect the .NET way:
AccessDataSource, SqlDataSource and connecting to Access databases in ASP.NET
All-Star
25756 Points
7014 Posts
Re: how do i use a UDL file?
Jul 01, 2009 09:20 AM|hans_v|LINK
ODBC - Access - ASP.NET
Not a very good combination
, always use OleDb
Member
676 Points
257 Posts
Re: how do i use a UDL file?
Jul 01, 2009 10:52 AM|chandu2chandu1|LINK
I am not sure that oleDb works for access or not. That's why I provided the sample example.
[Albert Einstein]
Regards,
Chandu
All-Star
25756 Points
7014 Posts
Re: how do i use a UDL file?
Jul 01, 2009 11:29 AM|hans_v|LINK
A common Connectionstring would look something like
Provider=Microsoft.Jet.OleDb.4.0;Data Source=|DataDirectory|myDB.mdb
Also, th AccessDatasource control uses the OleDb provider
http://msdn.microsoft.com/en-us/library/8e5545e1.aspx
None
0 Points
2 Posts
Re: how do i use a UDL file?
Jun 25, 2013 07:52 AM|berkut2006|LINK
Try this:
Basic database connection string C# and Sql Server using UDL file