how do i use a UDL file?

Last post 07-01-2009 11:29 AM by hans_v. 6 replies.

Sort Posts:

  • how do i use a UDL file?

    07-01-2009, 3:00 AM
    • Member
      69 point Member
    • young345
    • Member since 02-04-2008, 4:32 PM
    • Posts 405

    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

  • Re: how do i use a UDL file?

    07-01-2009, 5:50 AM
    • Participant
      1,505 point Participant
    • Ambran
    • Member since 03-18-2009, 2:23 PM
    • Denmark
    • Posts 286

    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


    If this post was of any help to you, Mark it as Answer for the benefit of others, Thanks.

    Spread Firefox Firebug - Web Development Evolved
  • Re: how do i use a UDL file?

    07-01-2009, 6:11 AM
    • Participant
      1,014 point Participant
    • chandu2chandu1
    • Member since 03-23-2007, 6:06 AM
    • Bangalore, India
    • Posts 233

    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.
    }



    Imagination is more important than knowledge..
    [Albert Einstein]

    Regards,
    Chandu

    My Blog
  • Re: how do i use a UDL file?

    07-01-2009, 9:15 AM
    • Star
      9,496 point Star
    • hans_v
    • Member since 01-29-2007, 4:03 PM
    • Posts 1,645

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

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

  • Re: how do i use a UDL file?

    07-01-2009, 9:20 AM
    • Star
      9,496 point Star
    • hans_v
    • Member since 01-29-2007, 4:03 PM
    • Posts 1,645

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


     

    ODBC - Access - ASP.NET

    Not a very good combinationCry, always use OleDb Laughing 

  • Re: how do i use a UDL file?

    07-01-2009, 10:52 AM
    • Participant
      1,014 point Participant
    • chandu2chandu1
    • Member since 03-23-2007, 6:06 AM
    • Bangalore, India
    • Posts 233

    hans_v:

    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.

    Imagination is more important than knowledge..
    [Albert Einstein]

    Regards,
    Chandu

    My Blog
  • Re: how do i use a UDL file?

    07-01-2009, 11:29 AM
    Answer
    • Star
      9,496 point Star
    • hans_v
    • Member since 01-29-2007, 4:03 PM
    • Posts 1,645

    chandu2chandu1:
    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

Page 1 of 1 (7 items)