VBScript SQL Server connection string problem

Problem in determine my database connection string.

Page 1 of 1

2 Replies - 8135 Views - Last Post: 07 September 2009 - 07:23 PM Rate Topic: -----

#1 dunk_6  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 43
  • Joined: 03-August 09

VBScript SQL Server connection string problem

Posted 03 September 2009 - 01:16 AM

Im having problem to determine what is provider and data source for my connection string. Please im really stuck, I try follow this example, but still dont know what to do..http://www.connectio...sql-server-2005. For your info, i'm using SQL Server 2005, and how to find those info in my machine??

Dim conn , rs, sql
sql = "SELECT * FROM tblOutbox"
Set conn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
With conn
	  .Provider = "SQLNCLI"
	  .Mode = adModeReadWrite	
	  .ConnectionString = "Data Source= .\SQLEXPRESS;AttachDbFilename=f:\Status.mdf;Database=Status;Trusted_Connection=Yes;"	   
	  .Open 
End With
If conn.State = adStateOpen Then
	WScript.Echo "Connection was established."
End If
conn.Close
Set conn = Nothing



Is This A Good Question/Topic? 0
  • +

Replies To: VBScript SQL Server connection string problem

#2 vb5prgrmr  Icon User is offline

  • D.I.C Lover

Reputation: 109
  • View blog
  • Posts: 1,016
  • Joined: 21-March 09

Re: VBScript SQL Server connection string problem

Posted 04 September 2009 - 09:00 PM

You need to scroll down that page a little further to get into the correct connection strings you want to use. Presently you are using a SQLExpress connection string that attaches a db to the instance of SQLExpress.

Now, if you look on that same page you will see...

Use serverName\instanceName as Data Source to connect to a specific SQL Server instance.

Are you using SQL Server 2005 Express? Don't miss the server name syntax Servername\SQLEXPRESS where you substitute Servername with the name of the computer where the SQL Server 2005 Express installation resides.

So the data source is the name of the computer.

As for the provider, the provider is the many options you have to connect to a db engine whether that be access, sql, mysql, progress, alpha5, etc. To see what you have on your computer you can check it by administrative tool>data sources (odbc). Click on add and scroll through the options, this will only give you an idea of how many and different types you have on your computer but will not really help you in identifying which provider you need to use, that is what the reems of MS documentation or the website you referenced are for.



Good Luck
Was This Post Helpful? 1
  • +
  • -

#3 dunk_6  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 43
  • Joined: 03-August 09

Re: VBScript SQL Server connection string problem

Posted 07 September 2009 - 07:23 PM

View Postvb5prgrmr, on 4 Sep, 2009 - 08:00 PM, said:

You need to scroll down that page a little further to get into the correct connection strings you want to use. Presently you are using a SQLExpress connection string that attaches a db to the instance of SQLExpress.

Now, if you look on that same page you will see...

Use serverName\instanceName as Data Source to connect to a specific SQL Server instance.

Are you using SQL Server 2005 Express? Don't miss the server name syntax Servername\SQLEXPRESS where you substitute Servername with the name of the computer where the SQL Server 2005 Express installation resides.

So the data source is the name of the computer.

As for the provider, the provider is the many options you have to connect to a db engine whether that be access, sql, mysql, progress, alpha5, etc. To see what you have on your computer you can check it by administrative tool>data sources (odbc). Click on add and scroll through the options, this will only give you an idea of how many and different types you have on your computer but will not really help you in identifying which provider you need to use, that is what the reems of MS documentation or the website you referenced are for.



Good Luck



Yes, its running OK...even though im not sure what have i done. your explanation is kind of hard to understand, but i still can follow some of it.. :P ..BTW thank you much for the help.

ConnString = "Provider=SQLNCLI; SERVER=.\SQLExpress;AttachDbFilename=F:\Admin.mdf;Database=Admin.mdf; Trusted_Connection=Yes;"

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1