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. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
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'? |
|
|
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 |
|
|
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] |
|
|
dd121
Starting Member
11 Posts |
Posted - 2010-11-15 : 06:56:27
|
i got instance specific/network specific error |
|
|
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 |
|
|
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 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
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 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|