UK WEB HOSTING FORUM FOR DISCUSSION ON WEB HOSTING SERVICE AND SUPPORT
LINUX HOSTING WINDOWS HOSTING PACKAGES SHOPPING CART OSCOMMERCE ZEN CART AGORA
ECOMMERCE HOSTING ASP MSSQL FRONTPAGE HOSTING PHP MYSQL HOSTING DISCUSSION FORUM
CPANEL RESELLER HOSTING DEDICATED SERVER VPS HOSTING PLESK VIRTUOZZO
Quick Search
Your forum announcement here!

  UK Web Hosting | Dedicated Server Windows and Linux VPS Forum > Technical Support > Windows Reseller Hosting

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-07-2007, 06:43
System Administrator
 
Join Date: Dec 2006
Location: localhost
Posts: 726
Lightbulb MSSQL 2005 connection strings

SQL Server 2005

This is a compiled connection strings reference list on how to connect to SQL Server 2005.
SQL Native Client ODBC Driver

Standard security
Quote:
Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase ;Uid=myUsername;Pwd=myPassword;
If you are 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.

Trusted Connection
Quote:
Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase ;Trusted_Connection=yes;
Equivalent key-value pair: "Integrated Security=SSPI" equals "Trusted_Connection=yes"

Prompt for username and password
This one is a bit tricky. First you need to set the connection object's Prompt property to adPromptAlways. Then use the connection string to connect to the database.

Quote:
oConn.Properties("Prompt") = adPromptAlways

Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase ;
Enabling MARS (multiple active result sets)
Quote:
Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase ;Trusted_Connection=yes;MARS_Connection=yes;
Equivalent key-value pair: "MultipleActiveResultSets=true" equals "MARS_Connection=yes"
Use ADO.NET 2.0 for MARS functionality. MARS is not supported in ADO.NET 1.0 nor ADO.NET 1.1.

Encrypt data sent over network
Quote:
Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase ;Trusted_Connection=yes;Encrypt=yes;
Attach a database file on connect to a local SQL Server Express instance
Quote:
Driver={SQL Native Client};Server=.\SQLExpress;AttachDbFilename=c:\ab c\xyz\mydbfile.mdf;Database=dbname;Trusted_Connect ion=Yes;
Why is the Database parameter needed? If the named database have already been attached, SQL Server does not reattach it. It uses the attached database as the default for the connection.

Attach a database file, located in the data directory, on connect to a local SQL Server Express instance
Quote:
Driver={SQL Native Client};Server=.\SQLExpress;AttachDbFilename=|Data Directory|mydbfile.mdf;Database=dbname;Trusted_Con nection=Yes;
Why is the Database parameter needed? If the named database has already been attached, SQL Server does not reattach it. It uses the attached database as the default for the connection.

Database mirroring
If you connect with ADO.NET or the SQL Server Native Client to a database that is being mirrored, your application can take advantage of the drivers ability to automatically redirect connections when a database mirroring failover occurs. You must specify the initial principal server and database in the connection string and the failover partner server.

Quote:
Data Source=myServerAddress;Failover Partner=myMirrorServer;Initial Catalog=myDataBase;Integrated Security=True;
There is ofcourse many other ways to write the connection string using database mirroring, this is just one example pointing out the failover functionality.

SQL Native Client OLE DB Provider

Standard security
Quote:
Provider=SQLNCLI;Server=myServerAddress;Database=m yDataBase;Uid=myUsername;Pwd=myPassword;
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.

Trusted connection
Quote:
Provider=SQLNCLI;Server=myServerAddress;Database=m yDataBase;Trusted_Connection=yes;
Equivalent key-value pair: "Integrated Security=SSPI" equals "Trusted_Connection=yes"

Prompt for username and password
This one is a bit tricky. First you need to set the connection object's Prompt property to adPromptAlways. Then use the connection string to connect to the database.

Quote:
oConn.Properties("Prompt") = adPromptAlways

oConn.Open "Provider=SQLNCLI;Server=myServerAddress;DataBase=m yDataBase;
Enabling MARS (multiple active result sets)
Quote:
Provider=SQLNCLI;Server=myServerAddress;Database=m yDataBase;Trusted_Connection=yes;MarsConn=yes;
Equivalent key-value pair: "MultipleActiveResultSets=true" equals "MARS_Connection=yes"
Use ADO.NET 2.0 for MARS functionality. MARS is not supported in ADO.NET 1.0 nor ADO.NET 1.1.

Encrypt data sent over network
Quote:
Provider=SQLNCLI;Server=myServerAddress;Database=m yDataBase;Trusted_Connection=yes;Encrypt=yes;
Attach a database file on connect to a local SQL Server Express instance
Quote:
Provider=SQLNCLI;Server=.\SQLExpress;AttachDbFilen ame=c:\asd\qwe\mydbfile.mdf;Database=dbname;Truste d_Connection=Yes;
Why is the Database parameter needed? If the named database have already been attached, SQL Server does not reattach it. It uses the attached database as the default for the connection.

Attach a database file, located in the data directory, on connect to a local SQL Server Express instance
Quote:
Provider=SQLNCLI;Server=.\SQLExpress;AttachDbFilen ame=|DataDirectory|mydbfile.mdf;Database=dbname;Tr usted_Connection=Yes;
Why is the Database parameter needed? If the named database have already been attached, SQL Server does not reattach it. It uses the attached database as the default for the connection.

Database mirroring
If you connect with ADO.NET or the SQL Server Native Client to a database that is being mirrored, your application can take advantage of the drivers ability to automatically redirect connections when a database mirroring failover occurs. You must specify the initial principal server and database in the connection string and the failover partner server.

Quote:
Data Source=myServerAddress;Failover Partner=myMirrorServer;Initial Catalog=myDataBase;Integrated Security=True;
There are many other ways to write the connection string using database mirroring, this is just one example pointing out the failover functionality. You can combine this with the other connection strings options available.

Please refer the following URL for MSSQL 2000 connection strings: MSSQL 2000 connection strings
__________________

Rock _a.k.a._ Jack L.

http://www.eUKhost.com
Windows Hosting || Windows Reseller Hosting
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 07-07-2007, 06:57
System Administrator
 
Join Date: Dec 2006
Location: localhost
Posts: 726
Lightbulb MSSQL 2005 connection strings (ASP.Net special)

Hi... Update to the above post...

The following will help you in connecting to the MSSQL 2005 Database using ASP.Net.

SqlConnection (.NET)

Standard Security

Quote:
Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;
Use serverName\instanceName as Data Source to connect to a specific SQL Server instance.
If you are 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.

Standard Security alternative syntax
This connection string produce the same result as the previous one. The reason to include it is to point out that some connection string keywords have many equivalents.

Quote:
Server=myServerAddress;Database=myDataBase;User ID=myUsername;Password=myPassword;Trusted_Connecti on=False;
Trusted Connection
Quote:
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;
Trusted Connection alternative syntax
This connection string produce the same result as the previous one. The reason to include it is to point out that some connection string keywords have many equivalents.

Quote:
Server=myServerAddress;Database=myDataBase;Trusted _Connection=True;
Connect via an IP address
Quote:
Data Source=10.10.10.10,1433;Network Library=DBMSSOCN;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;
DBMSSOCN=TCP/IP. This is how to use TCP/IP instead of Named Pipes. At the end of the Data Source is the port to use. 1433 is the default port for SQL Server.

Enabling MARS (multiple active result sets)
Quote:
Server=myServerAddress;Database=myDataBase;Trusted _Connection=True;MultipleActiveResultSets=true;
Use ADO.NET 2.0 for MARS functionality. MARS is not supported in ADO.NET 1.0 nor ADO.NET 1.1.

Attach a database file on connect to a local SQL Server Express instance
Quote:
Server=.\SQLExpress;AttachDbFilename=c:\abc\xyz\my dbfile.mdf;Database=dbname;Trusted_Connection=Yes;
Why is the Database parameter needed? If the named database have already been attached, SQL Server does not reattach it. It uses the attached database as the default for the connection.

Attach a database file, located in the data directory, on connect to a local SQL Server Express instance
Quote:
Server=.\SQLExpress;AttachDbFilename=|DataDirector y|mydbfile.mdf;Database=dbname;Trusted_Connection= Yes;
Why is the Database parameter needed? If the named database have already been attached, SQL Server does not reattach it. It uses the attached database as the default for the connection.

Using an User Instance on a local SQL Server Express instance
The User Instance functionality creates a new SQL Server instance on the fly during connect. This works only on a local SQL Server 2005 instance and only when connecting using windows authentication over local named pipes. The purpose is to be able to create a full rights SQL Server instance to a user with limited administrative rights on the computer.
Quote:
Data Source=.\SQLExpress;Integrated Security=true;AttachDbFilename=|DataDirectory|\myd b.mdf;User Instance=true;
To use the User Instance functionality you need to enable it on the SQL Server. This is done by executing the following command: sp_configure 'user instances enabled', '1'. To disable the functionality execute sp_configure 'user instances enabled', '0'.

Database mirroring
If you connect with ADO.NET or the SQL Server Native Client to a database that is being mirrored, your application can take advantage of the drivers ability to automatically redirect connections when a database mirroring failover occurs. You must specify the initial principal server and database in the connection string and the failover partner server.
Quote:
Data Source=myServerAddress;Failover Partner=myMirrorServer;Initial Catalog=myDataBase;Integrated Security=True;
There is ofcourse many other ways to write the connection string using database mirroring, this is just one example pointing out the failover functionality. You can combine this with the other connection strings options available.


Asynchronous processing
A connection to SQL Server 2005 that allows for the issuing of async requests through ADO.NET objects.
Quote:
Server=myServerAddress;Database=myDataBase;Integra ted Security=True;Asynchronous Processing=True;
Hope this'll help a lot of people in quickly getting their databases attached to their web-pages/scripts...
__________________

Rock _a.k.a._ Jack L.

http://www.eUKhost.com
Windows Hosting || Windows Reseller Hosting
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 13-08-2007, 12:10
new member
 
Join Date: Aug 2007
Posts: 5
Default Error connecting to MS SQL Server Express

Hi Rock,

I am new here and am loading a website hosting www.youbayou.info which uses a MS SQL Server express database. I use the following connection string:
"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\YoubayouDB.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"
which works fine on the development enviroment but uploaded it does not work and I have the following error:
" Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed.
"

Can anyone helps me with this please?


Korbay
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 14-08-2007, 00:07
System Administrator
 
Join Date: Dec 2006
Location: localhost
Posts: 726
Lightbulb

Korbay,

Your issue was fixed & replied in a different thread : MS SQL Server Express path
Let us know if you need any further help with anything else.
__________________

Rock _a.k.a._ Jack L.

http://www.eUKhost.com
Windows Hosting || Windows Reseller Hosting
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 14-08-2007, 17:08
new member
 
Join Date: Aug 2007
Posts: 12
Post connection String

Hi Rock,

I have just switched to this josting service. Today i tried to upload my database to server, but could not succeed. Please let me know the exact connection string. i am using following one




I shall be thank ful, if u please correct errors if any !

prash

Last edited by prash; 14-08-2007 at 17:11.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 14-08-2007, 17:13
new member
 
Join Date: Aug 2007
Posts: 12
Default

Hi rock
here is my connection string, which seems to be erroneous. Please correct and oblige.
Thanking you
prashant

connectionString="Data Source=87.117.238.85\SQLEXPRESS;Network Library=DBMSSOCN;Initial Catalog=xxxx_xxxx;User ID=xxxx_admin;Password=xxxx;"/>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 14-08-2007, 17:29
flesso's Avatar
Premium Member
 
Join Date: Mar 2007
Location: 127.0.0.1
Posts: 1,462
Default

Quote:
Originally Posted by prash View Post
Hi rock
here is my connection string, which seems to be errorneous. Please correct and oblige.
Thanking you
prashant

connectionString="Data Source=87.117.238.85\SQLEXPRESS;Network Library=DBMSSOCN;Initial Catalog=xxxx_xxxx;User ID=xxxx_admin;Password=xxxxx;"/>
Where are you adding this? By the look of the ending it looks as if it's in the web.config file. If it's in the web.config file it should be the following:

PHP Code:
 <add key="ConnectionString" value="Provider=sqloledb;Data Source=vaiolaptop\VSdotNET;Initial Catalog=example;User Id=example;Password=xxxx;" /> 
__________________
Regards,
Josh Hold

eUKhost Blog: Over 1000 Computer Related Articles to Sink Your Teeth Into!

LDN GIGS - Gig Listings for London

Super Moderator

I'm only a forum gremlin (moderator), and do not work for eUKhost in any way. Opinions expressed by me are mine only, and do not reflect those of either eUKhost or any company that may be listed above.

I don't bite, honest.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 14-08-2007, 17:46
new member
 
Join Date: Aug 2007
Posts: 12
Default

hi,
Well i am doing it in asp.net 2.0
and i am trying to paste entire connection string code here, but this forum is not accepting.

Quote:
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 14-08-2007, 17:50
new member
 
Join Date: Aug 2007
Posts: 12
Default

hi there

here is code that i am using in

add name="ImageGalleryConnectionString" connectionString="Data Source=87.117.238.85\SQLEXPRESS;Initial Catalog=xxxx_xxxx;User Id=xxxx_admin;Password=#xxxx#;"/>

Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 14-08-2007, 18:06
flesso's Avatar
Premium Member
 
Join Date: Mar 2007
Location: 127.0.0.1
Posts: 1,462
Default

Quote:
Originally Posted by prash View Post
hi there

here is code that i am using in

add name="ImageGalleryConnectionString" connectionString="Data Source=87.117.238.85\SQLEXPRESS;Initial Catalog=xxxx_xxxe;User Id=xxxx_admin;Password=#xxxx#;"/>

Thanks
That's totally incorrect. Use the example I gave, by adding it to the web.config file of your app and then you should be getting somewhere.
__________________
Regards,
Josh Hold

eUKhost Blog: Over 1000 Computer Related Articles to Sink Your Teeth Into!

LDN GIGS - Gig Listings for London

Super Moderator

I'm only a forum gremlin (moderator), and do not work for eUKhost in any way. Opinions expressed by me are mine only, and do not reflect those of either eUKhost or any company that may be listed above.

I don't bite, honest.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #11 (permalink)  
Old 14-08-2007, 18:13
new member
 
Join Date: Aug 2007
Posts: 12
Default

hi thanks for your reply and correction. what information should i provide for PROVIDER AND SOURCE.

i am using this address info [87.117.238.85\SQLEXPRESS ] to connect to management studio

provider and source
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)  
Old 14-08-2007, 18:19
flesso's Avatar
Premium Member
 
Join Date: Mar 2007
Location: 127.0.0.1
Posts: 1,462
Default

Quote:
Originally Posted by prash View Post
hi thanks for your reply and correction. what information should i provide for PROVIDER AND SOURCE.

i am using this address info [87.117.238.85\SQLEXPRESS ] to connect to management studio

provider and source


You need to change the following words/sections:

databse = Your database name.
dbusername = Your database username.
dbpass = Your database password.

That should get you going.
__________________
Regards,
Josh Hold

eUKhost Blog: Over 1000 Computer Related Articles to Sink Your Teeth Into!

LDN GIGS - Gig Listings for London

Super Moderator

I'm only a forum gremlin (moderator), and do not work for eUKhost in any way. Opinions expressed by me are mine only, and do not reflect those of either eUKhost or any company that may be listed above.

I don't bite, honest.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #13 (permalink)  
Old 14-08-2007, 18:45
new member
 
Join Date: Aug 2007
Posts: 12
Default

hi there
it still is not working !!

here is my code of connection string. This should help u find, whats wrong. Please correct.
PHP Code:
<connectionStrings>
    <
add key="ConnectionString" value="Provider=sqloledb;Data Source=vaiolaptop\VSdotNET;Initial Catalog=xxxx_xxxx;User Id=xxxx_admin;Password=#silsilay#;" />
    <
add key="ConnectionString" value="Provider=sqloledb;Data Source=vaiolaptop\VSdotNET;Initial Catalog=xxxx_xxxx;User Id=xxxx_admin;Password=#silsilay#;" />
    <
add key="ConnectionString" value="Provider=sqloledb;Data Source=vaiolaptop\VSdotNET;Initial Catalog=xxxx_xxe;User Id=xxxx_admin;Password=#xxxx#;" />
    
        
  </
connectionStrings
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #14 (permalink)  
Old 15-08-2007, 11:33
eUK-Martin's Avatar
Windows System Administrator
 
Join Date: Nov 2005
Location: Earth
Posts: 462
Default

Quote:
Originally Posted by prash View Post
hi there
it still is not working !!

here is my code of connection string. This should help u find, whats wrong. Please correct.
I would suggest you to please email us on windows [at] eukhost.com and we will take care of your issue.

Please include the affected domain name and database details.
__________________
Martin
Windows System Admin.


Windows VPS Hosting - Windows Dedicated Server - Web Hosting Tutorials

Email :: windows @ eUKhost.com AND support @ eUKhost.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #15 (permalink)  
Old 15-08-2007, 20:38
System Administrator
 
Join Date: Dec 2006
Location: localhost
Posts: 726
Thumbs up

Hi Prash,

Here are the changes that were into the web.config file that worked...
PHP Code:
<add name="ImageGalleryConnectionString" connectionString="Data Source=RxxxxR\SQLEXPRESS;Initial Catalog=xxxxxx;User ID=xxxxxx;Password=#xxxxx#" providerName="System.Data.SqlClient" /> 
__________________

Rock _a.k.a._ Jack L.

http://www.eUKhost.com
Windows Hosting || Windows Reseller Hosting
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #16 (permalink)  
Old 14-10-2007, 19:05
Junior Member
 
Join Date: Oct 2007
Posts: 17
Default Ok, I've read this thread over and over, and I'm still too stupid...

My connection string is:

Data Source=91.186.30.8:8443\SQLEXPRESS;Initial Catalog=DivineDB;User Id=sa;Password=#password#;Persist Security Info=True;"
providerName="System.Data.SqlClient" />

but I get (having enabled debug mode):

"An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Server Network Interfaces, error: 25 - Connection string is not valid)"

Which I guess means that I've got it wrong

The page I'm working on is: http://image-machine.com/content/gue...guestbook.aspx

Any clues, please?