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
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 New to SQL Server

Author  Topic 

jimmyray
Starting Member

4 Posts

Posted - 2009-12-23 : 16:46:37
Hi,

I have created an application with Visual Studio 2005 and have it installed on my pc. I am using SQL Server 2005 and think I am missing something. When I tyr to login to my application it gives me an error...

The connection to the database can't be established.

Can anyone help?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-12-23 : 16:58:31
Can you connect to SQL Server 2005 via Management Studio?

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

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

jimmyray
Starting Member

4 Posts

Posted - 2009-12-23 : 17:28:23
Yeah, I can login through the management studio.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-12-23 : 17:29:01
If it works there, then you need to verify your connection string as something is wrong in it.

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

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

jimmyray
Starting Member

4 Posts

Posted - 2009-12-28 : 12:01:42
Ok here is my connection string. Not sure what i am doing wrong. Like I said...I am new at this.

<add name="ARS.My.MySettings.ARSConnectionString" connectionString="Data Source=(local);Initial Catalog=ARSSRV;Integrated Security=SSPI"
providerName="System.Data.SqlClient" />

ARSSRV is on server MANI-PC\SQLEXPRESS
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2009-12-28 : 13:09:46
If the main server is different from the PC u installed it on, then you have to change your connection string to non trusted and put a username and password.

also change the data source from local to the server address.

see this www.connectionstrings.com

Also in Vstudio, did you add database or add connection ???
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-12-28 : 13:10:39
Try using MANI-PC,PortNumber where PortNumber is the port that the SQLEXPRESS instance is listening on.

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

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2009-12-28 : 14:02:52
If you added a db, then you shouldnt have a problem.

But if it was an external source then you have to modify it
Go to Top of Page

jimmyray
Starting Member

4 Posts

Posted - 2009-12-28 : 14:40:22
Awesome that worked. Thanks! So that makes it work on my pc. How would i get it to work on a client pc after my program is installed??
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-12-28 : 14:47:35
You can put that in your connection string or just add aliases to the client machines.

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

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2009-12-28 : 19:01:48
If you are using winforms, put your connection string in a central location in your app.config file.

If you are using WPF, put the connection string in the resources settings.

Then where ever you have to set a data connection in your program, make a variable reference to it using ADO.NET
Go to Top of Page
   

- Advertisement -