Tuesday, 7 May 2013

Use string builder to create connection string.


 Use this string builder to create your Sql connection string


Public Function CreateConnectionString(ByVal strUserName As String, ByVal strPassword As String) As String
        On Error GoTo err
        Dim strConnBuilder As New SqlConnectionStringBuilder


        With strConnBuilder
            .ApplicationName = "Your Application Name"
            .AsynchronousProcessing = False
            .ConnectTimeout = 20
            .IntegratedSecurity = True
            .NetworkLibrary = "DBMSSOCN"
            .MinPoolSize = 1
            .MaxPoolSize = 50
            .DataSource = "Your SQL server name or IP Address"
            .InitialCatalog = "Your database name"

        End With
        Return strConnBuilder.ConnectionString
        Exit Function
err:
        errormsg("SysModule-CreateConnectionString" & Err.Description)
    End Function


Call somthing like this
 sqlCon1 As New SqlConnection(CreateConnectionString("", ""))

No comments:

Post a Comment

Samsung Android Keyboard

  If you have a Samsung phone or pad and the keyboard is set to Google give the Samsung one a try. Just go into the keyboard settings and ...