Create An OLEDB Connection String for SQL Server

Search

 by Remas Wojciechowski

This function returns a standard OLEDB connection string for SQL Server.

Parameters

strIP
The URI of the database server
strDB
The name of the database
strUser
The User ID
strPwd
The Password

Source Code

' ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
' Function: db_OLEDB_SQLServer
'
'
Function db_OLEDB_SQLServer(ByVal strIP, ByVal strDB, ByVal strUser, ByVal strPwd)
  Dim strTemp
  Dim strPattern
  strPattern = "Provider=SQLOLEDB; Data Source=%1; Initial Catalog=%2; User ID=%3; Password=%4"
  strTemp = Replace(strPattern, "%1", strIP)
  strTemp = Replace(strTemp, "%2", strDB)
  strTemp = Replace(strTemp, "%3", strUser)
  strTemp = Replace(strTemp, "%4", strPwd)
  db_OLEDB_SQLServer = strTemp
End Function