CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: App to DB

  1. #1
    Join Date
    May 2004
    Posts
    249

    App to DB

    I know this question may have been asked before, but let me ask this one more time...

    what are some ways in which an App can be linked to a DB?

    The first answer i will get is via connection strings.

    http://www.connectionstrings.com/

    But i would like to know how else can it be possible to link an app [that would be used on a LAN/WAN] to a DB that is dynamically stored on a LAN/WAN (NOT online/cloud)
    --------------------------------------------------
    Please pardon me for having bad English.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: App to DB

    What prevents you to use connection strings?
    Victor Nijegorodov

  3. #3
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: App to DB

    Connection strings are simply a way to direct a database provider to where your database is located.

    As far as database providers, there are many different types such as ADO.Net and Entity Framework to name a few.


    Connection strings are going to do anything on their own - they need to be used with a data provider.

  4. #4
    Join Date
    May 2004
    Posts
    249

    Re: App to DB

    Quote Originally Posted by VictorN View Post
    What prevents you to use connection strings?
    nothing is preventing me from using connection strings. I am just trying to broaden my knowledge thats all.

    Arjay, i mostly work with MS applications. and for my very first small project i am using MS Access 2010 to be exact and Visual C# 2012 Express
    --------------------------------------------------
    Please pardon me for having bad English.

  5. #5
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: App to DB

    Quote Originally Posted by rockx View Post
    nothing is preventing me from using connection strings. I am just trying to broaden my knowledge thats all.

    Arjay, i mostly work with MS applications. and for my very first small project i am using MS Access 2010 to be exact and Visual C# 2012 Express
    Just to be clear, connection strings don't do anything on their own - you need a database provider to use them with and need to use a provider that allows you to connect with your data.

    For MS Access, you can use the OleDbConnection provider.

    Code:
    var connStr = @"Provider=Microsoft.Jet.OLEDB.4.0;Data source= C:\Documents and Settings\username\My Documents\AccessFile.mdb";
    
    using(var conn = new OleDbConnection(connStr))
    {
        try
        {
            conn.Open();
    
            using(var cmd = new OleDbCommand(conn))
            {
               // Insert code to process data
            } 
        }
        catch (Exception ex)
        {
            // handle error
        }
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured