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
 .NET Inside SQL Server (2005)
 Data Source issue

Author  Topic 

dd121
Starting Member

11 Posts

Posted - 2010-11-14 : 10:32:52
on my laptop, the data source for SQL server 2008 is :


Data Source=PC\SQLEXPRESS;Initial Catalog=finaldb;Integrated Security=True


But when i deploy this application software, the new computer which installs this will not have "PC\SQLEXPRESS" as their SQL server name instance. How will i make sure they can also connect to this databasE?

chadmat
The Chadinator

1974 Posts

Posted - 2010-11-14 : 18:50:31
Use a config file, and pull the connection string from there.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-11-14 : 21:21:44
Whoah! I spot chadmat! It's been years since you've visited here. What's up?

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

Subscribe to my blog
Go to Top of Page

dd121
Starting Member

11 Posts

Posted - 2010-11-15 : 05:11:24
This is my first time with database application. Can u tell me wht u mean by 'use a config file'?
Go to Top of Page

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2010-11-15 : 05:39:49
Your application will/can have a config file e.g. app.config. Store the connection string there as chadmat says.

-----------

I used to think I wasn't a morning person but it never got better in the afternoon
Go to Top of Page

dd121
Starting Member

11 Posts

Posted - 2010-11-15 : 06:55:37
[code]
conn = new System.Data.SqlClient.SqlConnection();
conn.ConnectionString = "Data Source= PC\\SQLEXPRESS;Initial Catalog=finaldb;Integrated Security=True";

[/code]

i changed it to:

[code]
conn = new System.Data.SqlClient.SqlConnection();
conn.ConnectionString = "Data Source=|DataDirectory|\testdb.sdf";
conn.Open();
[/code]

after seeing this in the app.config file:

[code]
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="WindowsFormsApplication2.Properties.Settings.testdbConnectionString"
connectionString="Data Source=|DataDirectory|\testdb.sdf"
providerName="Microsoft.SqlServerCe.Client.3.5" />
<add name="WindowsFormsApplication2.Properties.Settings.finaldbConnectionString"
connectionString="Data Source=PC\SQLEXPRESS;Initial Catalog=finaldb;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
[/code]
Go to Top of Page

dd121
Starting Member

11 Posts

Posted - 2010-11-15 : 06:56:27
i got instance specific/network specific error
Go to Top of Page

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2010-11-15 : 08:44:20
This [url]http://msdn.microsoft.com/en-us/library/ms254494(VS.80).aspx[/url] explains how to store and access connection strings

-----------

I used to think I wasn't a morning person but it never got better in the afternoon
Go to Top of Page

chadmat
The Chadinator

1974 Posts

Posted - 2010-11-15 : 22:09:34
Tara,

For a while I was doing consulting and got away from SQL Server and more into .Net Dev and other stuff. I am now back at MS as a SQL PFE (Premier Field Engineer) doing onsite support for Premier customers, been doing that for a few years now. Anyway, I saw Graz in the keynote at SQL PASS last week, and it reminded me I should come back and visit SQLTeam

-Chad
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-11-15 : 23:32:07
Is a PFE the same thing as a DSE? My company is a premier customer of MS and have purchased a few hundred DSE hours. It has been invaluable so far!

DSE=dedicated support engineer

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

Subscribe to my blog
Go to Top of Page

chadmat
The Chadinator

1974 Posts

Posted - 2010-11-16 : 02:10:54
Yep,

A PFE can be dedicated (DSE) or Transactional. I am Transactional, so not dedicated to a customer. Who is your DSE?

-Chad
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-11-16 : 12:45:26
I'll send you a PM with his name.

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 -