Connection

  • Could you please advise me which way is better to connect to the SQL server from Visual Basic application - udl file or Connection object?

    I know that connection object gives more flexibility, is there any other cons?

    Thank you.

  • It's really two ways of doing the same thing. One way or another to open a connection (a connection object in ADO) you have to have the server name, the databasename, and either a trusted connection/NT login OR a sql login/password.

    HOW you get those is the subject of many debates! A UDL is an easy way to administer those settings and keep that administration external to your application. If the server name changes (or other item), just change the UDL. On the minus side, UDL's are NOT secure being plain text. They also represent an additional item to consider during installation as well as a possible failure point if missing. Just compare those potential problems with the alternative of having to recompile your app each time server name (or other item) changes.

    There is a trick associated with UDL's you may find handy - build the UDL and test, then rename it with a .txt extension. Open in Notepad and you will have a complete ready to go ADO connect string.

    Andy

  • [Thank you very much.

    Liya

    ]

    It's really two ways of doing the same thing. One way or another to open a connection (a connection object in ADO) you have to have the server name, the databasename, and either a trusted connection/NT login OR a sql login/password.

    HOW you get those is the subject of many debates! A UDL is an easy way to administer those settings and keep that administration external to your application. If the server name changes (or other item), just change the UDL. On the minus side, UDL's are NOT secure being plain text. They also represent an additional item to consider during installation as well as a possible failure point if missing. Just compare those potential problems with the alternative of having to recompile your app each time server name (or other item) changes.

    There is a trick associated with UDL's you may find handy - build the UDL and test, then rename it with a .txt extension. Open in Notepad and you will have a complete ready to go ADO connect string.

    Andy

    [/quote]

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply