locked
how do i use a UDL file? RRS feed

  • Question

  • User997641556 posted

    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

    Wednesday, July 1, 2009 3:00 AM

Answers

  • User-1199946673 posted

    I am not sure that oleDb works for access or not.
     

    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

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 1, 2009 11:29 AM

All replies

  • User1007520750 posted

    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


    Wednesday, July 1, 2009 5:50 AM
  • User1896607475 posted

    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,

    string myConnString=ConfigurationaManager.ConnectionString["myConn"].ToString();
    using(ODBCConnection conn=new ODBCConnection())
    {
           //Do your database processing here.
    }



    Wednesday, July 1, 2009 6:11 AM
  • User-1199946673 posted

    Why would you use a UDL? Just connect the .NET way:

    AccessDataSource, SqlDataSource and connecting to Access databases in ASP.NET

    Wednesday, July 1, 2009 9:15 AM
  • User-1199946673 posted

    1. string myConnString=ConfigurationaManager.ConnectionString["myConn"].ToString();   
    2. using(ODBCConnection conn=new ODBCConnection())   
    3. {   
    4.        //Do your database processing here.   
    5. }  
    string myConnString=ConfigurationaManager.ConnectionString["myConn"].ToString();
    using(ODBCConnection conn=new ODBCConnection())
    {
           //Do your database processing here.
    }


     

    ODBC - Access - ASP.NET

    Not a very good combinationCry, always use OleDb Laughing 

    Wednesday, July 1, 2009 9:20 AM
  • User1896607475 posted

    ODBC - Access - ASP.NET

    Not a very good combinationCry, always use OleDb Laughing 

    I am not sure that oleDb works for access or not.  That's why I provided the sample example.

    Wednesday, July 1, 2009 10:52 AM
  • User-1199946673 posted

    I am not sure that oleDb works for access or not.
     

    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

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 1, 2009 11:29 AM
  • Tuesday, June 25, 2013 7:52 AM