ok i finally terminated a sql project.. Thanks God!
but.. 1 question remains:
this his the connection string used to connect to my DB
Data Source=MASTER\\SQLEXPRESS;Initial Catalog=tut;Integrated Security=True;Asynchronous Processing=True"
MASTER is my PC name;;
anyway i way to give to some friend thsi app so he can use it too..
but my app will connect to his database i mean the connection string wont be valid anymore.. so how can i make him automaticly detect or create the connection string..

sql connection string
Philippe
ok so i use.. GetDataSources method
but what if the user has sql server 2000 will it match i mean does it has any impotance
squash cat
So your connection string would become:
.\SQLEXPRESS;Initial Catalog=tut;Integrated Security=True;Asynchronous Processing=True
Jyothi Srinivasan MSFT
If you are running .NET 2.0 you may also use the new class SqlDataSourceEnumerator. You can use it as follows:
System.Data.Sql.SqlDataSourceEnumerator en = System.Data.Sql.SqlDataSourceEnumerator.Instance;
DataTable dt = en.GetDataSources ();
foreach (DataRow dr in dt.Rows) {... do whatever you want to determine if this is the correct instance ...
}
There is a good example in the msdn page. The DataTable that is returned contains a "ServerName", "InstanceName", "IsClustered" and "Version" columns. According to the documentation, the InstanceName will be empty if the instance is running as the default instance.
I tried the above, and it does identify all the computers running a SQL Server instance in the local network (I get the correct ServerName for all of them). What I don't get is the InstanceName of the SQL Server Express (it is returned empty, while I would have expected a "SQLEXPRESS"). The good news is that apparently SQL Server Express returns an empty version number...
HTH
--mc
mzKitty
Jim Bender
Hi,
assuming your friend used the default settings for the SQL instance, and you don't need anything fancy, you may simply try to change the machine name. You can get the computer name programmatically using the property:
System.Environment.MachineName
You might set your connection string to:
@"Data Source={0}\SQLEXPRESS;Initial Catalog=tut;Integrated Security=True;Asynchronous Processing=True"
string connStr = ... // get the string from wherever it is you keep it stored
string connectionString = string.Format (connStr, System.Environment.MachineName);
If you think your friend might have a full SQL Server and not just the express, you may want to try also with and withou the "\SQLEXPRESS".
Again, this is a rather crude solution, but if it's just a matter of passing an app to a friend it should probably suffice.
HTH
--mc
AshishBhatt_sys
Yes, it matches sql server 2000. It reports a different version number (8....) so you can distinguish the two, if needed. I couldn't test MSDE, so I cannot tell you what version is reported (as indicated before, SQL Server Express returns an empty version string).
--mc
terry_weasel