Connect to SQL Server

  • Print
Share this post
FaceBook  Twitter  Mixx.mn     


Connection string fro SQL Server, use following code:
Steps:

1) Create an ADODB connection  with provider as "sqloledb"

2) Open database connection

Code:

'Connect to SQL Server
'==============================================
Function Create_SQL_Connection(DataSource,Ini_catalog)
'1) Create an ADODB connection  with provider as "sqloledb"'
set SQLcon= CreateObject( "ADODB.Connection")
SQLcon.ConnectionString = "Provider='sqloledb';Data Source='" & DataSource & "';" & _
          "Initial Catalog='" & Ini_catalog & " ';Trusted_Connection=YES"
'2) Open database connection'
SQLcon.Open
End Function