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

Multi Point USB Charger

  USB Plug Charger, 4-Port USB Fast Charger Plug with 33W Intelligent Quick Charge 3.0 Wall Charger, Multi USBPower Adapter UK Fast Charging...