Calling Sql Server 2000 from C# Express

R

RvGrah

If I use a Sql Server 2005 Express copy of a database on my local
machine to develop my apps, can I then just substitute (Ctl+Shift + H
"replace all") the server name of my local machine with the server name
of our company server when I deploy this to my users?

I can't deploy versions calling my local development machine because
other apps talking to this same database are still based on VS 2003 and
some even from VB6, and they all need to talk to the same Sql Server.

Has anyone tried this? Yes, I'm going to try it myself, just loking for
input from fellow users. I want to get started in the VS 2005 world but
I'm not ready to buy the Professional version yet, want to see what I
can learn and do with Express version for a bit.

Thanx, Bob
 
N

Nicholas Paldino [.NET/C# MVP]

RvGrah,

Instead of hard coding your connection string, why not get that value
from a config file for your app? You should be able to do something like
this in your config file:

<connectionStrings>
<add name="MyLocalSQLServer"
connectionString="Initial Catalog=aspnetdb;
data source=localhost;Integrated Security=SSPI;"
providerName="System.Data.SqlClient"/>
</connectionStrings>

And then, in your code, you should be able to do:

// Get the connection string.
string connectionString =
System.Configuration.ConfigurationManager.ConnectionStrings["MyLocalSQLServer"];

Then, all you have to do is change the value in the config file, and you
don't have to worry about re-compiling your app anytime you want to specify
a different server.

Hope this helps.
 
R

RvGrah

Thanks Nicholas, Ill try that.
I almost addressed the question directly to you, as I was pretty sure
you'd be the one to answer it.

Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top