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

Chrome 138 the last supported

Chrome 138 the last supported  Hey Everyone, Chrome 138 is the last version of Chrome that will support Android 8.0 (Oreo) and Android 9.0 (...