1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

DNS or NOT DNS, that's the question

Discussion in 'C#' started by gworld, Aug 31, 2005.

  1. #1
    I want to use ASP with large MSSQL database (over 200,000 records), should I use DNS or direct connection string for database? It seems Microsoft recommends DNS but there is a discussion that is slower, so which one is a better alternative?
    SEMrush
     
    gworld, Aug 31, 2005 IP
    SEMrush
  2. Will.Spencer

    Will.Spencer NetBuilder

    Messages:
    14,789
    Likes Received:
    1,040
    Best Answers:
    0
    Trophy Points:
    375
    #2
    I'm confused. :eek:

    Do you mean DNS or DSN?
     
    Will.Spencer, Aug 31, 2005 IP
    Mia likes this.
  3. frankm

    frankm Active Member

    Messages:
    915
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    83
    #3
    I think he means DSN, and I would still recommend it, even if it is a bit slower than a direct connection name/string.
    You will thank me later when you have decided to change database server :)

    or in other words: if your system is that heavily loaded that the type of connection is an issue, you should get more hardware to support the needs of your applications.
     
    frankm, Aug 31, 2005 IP
  4. gworld

    gworld Prominent Member

    Messages:
    11,324
    Likes Received:
    615
    Best Answers:
    0
    Trophy Points:
    310
    #4
    Sorry, sometimes typing to fast is not a very good idea, I mean DSN.
     
    gworld, Aug 31, 2005 IP
  5. relixx

    relixx Active Member

    Messages:
    948
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    70
    #5
    Go for DSN all the way. It's more secure and it's easier to switch over to a new database if you want to, and the speed reduction isn't normally that serious.
     
    relixx, Sep 1, 2005 IP
  6. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    64
    Best Answers:
    0
    Trophy Points:
    0
    #6
    What people call DSN, means that you willbe using ODBC connections. What you call "direct connection" is an OLE DB connection. OLE DB is a native protocol and does it all - connection pooling, optimizations, etc. For non-MS DBMS, like MySQL, ODBC offers more mature and probably better-tested software. Going MS-to-MS, though, OLE DB is a better choice.

    J.D.
     
    J.D., Sep 1, 2005 IP
  7. nevetS

    nevetS Evolving Dragon

    Messages:
    2,544
    Likes Received:
    211
    Best Answers:
    0
    Trophy Points:
    135
    #7
    depends on what your future plans are. Since you are asking the question, your answer is DSN. It leaves more flexibility for you in the future (although it's not impossible to make a switch if you go ole-db, it will be much easier with a DSN). The performance consideration is not a large one, and believe it or not 200,000 records is a rather small database.
     
    nevetS, Sep 1, 2005 IP
  8. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    64
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Here's both. How's DSN help you switch easier?

    Connection.Open("Provider=SQLOLEDB.1;Data Source=machine;User ID=user;Password=password;");
    Connection.Open("DSN=dsn;UID=user;PWD=password")

    The right approach is to create a function that connects you to the database and call this function from everywhere. For example:

    <% @ language="jscript" %>
    function DbmsConnect1()
    {
       return Connection.Open("Provider=SQLOLEDB.1;Data Source=machine1;User ID=user1;Password=password1;");
    }
    function DbmsConnect2()
    {
       return Connection.Open("Provider=SQLOLEDB.1;Data Source=machine2;User ID=user2;Password=password2;");
    }
    ...
    var connection = DbmsConnect1();
    ...
    Code (markup):
    This way there's only one place in the code to change if any part of the database configuration changes.

    Connection type doesn't have anything to do with the size of the database. It affects how fast you connect, how fast you transfer data over the wire, how fast you convert data to your native types, how your connections are pooled, etc.

    J.D.
     
    J.D., Sep 2, 2005 IP
  9. nevetS

    nevetS Evolving Dragon

    Messages:
    2,544
    Likes Received:
    211
    Best Answers:
    0
    Trophy Points:
    135
    #9
    That's how things should work. In an ideal situation you are only changing one file that contains your connection info. In many situations, that connection information is repeated in multiple files. In this case, the chance of missing a file increases with the number of files containing a connection string. For a beginner - it's best to use a DSN because in that case you just end up changing one odbc file.

    Right. two separate thoughts there. Probably should have been different sentences or paragraphs.
     
    nevetS, Sep 2, 2005 IP