Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How can I test a connection string?

Author  Topic 

midi25
Starting Member

24 Posts

Posted - 2009-01-07 : 10:47:55
Hi I have a connection string to my DB and when I add it to the web config page of my application all I get is problems.

I want to be say with surety that my connection string is ok. ie rule out the connection as a problem.

How can I test to see if my connection has been established in sql. ?

Can it be done with a query?

Thanks

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-07 : 10:53:17
whats the error you get when you include it in webconfig?
Go to Top of Page

revdnrdy
Posting Yak Master

220 Posts

Posted - 2009-01-07 : 12:28:09
Just to make sure.. does your syntax in web config look like this?
Note I am presuming a .NET environment

<configuration>
<appSettings>
<add key="ConnectionString"
value="server=YourServerName;database=Northwind;uid=userID;password=secret;" />
</appSettings>
</configuration>

Also as already posted you could tell us what the reported error is.

It may also be the case that you have to restart the web server once you update the config file but I am not sure how your environment is setup. I know that apache web server requires this...

r&r
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-01-07 : 12:48:40
Post your error.

You shouldn't restart the web server when updating the config file. You just need to do an iisreset.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

midi25
Starting Member

24 Posts

Posted - 2009-01-07 : 13:42:05
The application that I am using has a section like this in the web config. Yes it is a .net environment.

<configuration>
<appSettings>
<add key="ConnectionString"
value="server=serve;database=jb;uid=john;password=bob;Intergrated Security=True;" />
</appSettings>
</configuration>

I,m not getting any meaningful errors on the error display page. All it tells me is to turn on remote errors or view the page on the local server. ie: mode="RemoteOnly" or "Off"
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-01-07 : 13:49:38
The way that we test our connection strings is to setup a test odbc system dsn with the same parameters as the connection string. Let us know if you get an error there and please provide the exact text of it.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

revdnrdy
Posting Yak Master

220 Posts

Posted - 2009-01-07 : 14:06:36
Ok shot in the dark...

Intergrated Security=True

is mis-spelled. Did you type that into your post to us or copy it in from the webconfig file? Intergrated should be spelled as Integrated
I would think it matters but again a shot in the dark..

r&r
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-01-07 : 14:30:24
If you want to use integrated security, then I don't think you can also pass uid/password in there. uid/password is used when Integrated security is false, so that sql authentication is used.

Please see www.connectionstrings.com for valid connection strings.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

midi25
Starting Member

24 Posts

Posted - 2009-01-07 : 16:06:36
Sorry i meant Integrated that was a typo.

I am using a login that I created myself for the database. So its SQL Authentication. I assume.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-01-07 : 16:08:18
If it's SQL authentication, then you can't use integrated security. Integrated security means Windows authentication which means to use the current security context and not a SQL login.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

midi25
Starting Member

24 Posts

Posted - 2009-01-07 : 16:28:05
I am using a login that I created in the db string.
eg: uid=john;pwd=123

so is this sql authentication?

Thanks
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-01-07 : 16:50:35
Yes, see the link I posted earlier for examples.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

midi25
Starting Member

24 Posts

Posted - 2009-01-07 : 17:58:10
Thats sites not too helpful for newbies.

are there any other sites that explain about all the sql connection string parameter meanings?

thanks
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-01-07 : 18:13:00
That's the best link I've got for connection strings.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

midi25
Starting Member

24 Posts

Posted - 2009-01-07 : 18:44:26
grrr. I just cant get this to connect man.

I have my SQL Express instance set to mixed mode.
I have a database called abc
i have created a login for the db called john
I have allowed remote connections through surface area
I have started the sql browser service
I can connect and successfully test the connection by creating a dsn using all the supplied details.

Finally I am using the following string in my web config.
Server=Pluto\SQLEXPRESS;database=abc;uid=john;pwd=123;

What could be wrong?

Thanks
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-01-07 : 18:46:25
It's hard to know without the error.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

midi25
Starting Member

24 Posts

Posted - 2009-01-09 : 05:29:24
I got to the bottom of this. The application instructions were poorly written.

In the connection string the example talked about using SQL authentication using Trusted Connection=True

I recreated the db and set the string in the web.config file to use the sql login for the db. And then set trusted connection to false.

It worked and the data is now being written to the tables.

Basically the instructions that I inherited where flawed. Something that I will make aware to the relevant people.

Thanks for the help.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-01-09 : 11:26:08
You're welcome, glad you were able to work through it.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -