Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: VB7
Expertise: Intermediate
Nov 17, 2003



Application Security Testing: An Integral Part of DevOps

CreateConnection - Creating a suitable connection object for a given connection string

' Create a suitable connection object for a given connection string.
' Requires Imports for System.Data, System.Data.Common, System.Data.OleDb,
'  System.Data.SqlClient and System.Data.Odbc
' Example: Dim cn As IDbConnection = CreateConnection(connStr)

Function CreateConnection(ByVal connString As String) As IDbConnection
    If connString.ToLower.IndexOf("provider=") >= 0 Then
        Return New OleDbConnection(connString)
    ElseIf connString.ToLower.IndexOf("driver") >= 0 Then
        Return New OdbcConnection(connString)
        Return New SqlConnection(connString)
    End If
End Function
Francesco Balena
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date