automatically detect server name and connect to the database


i creating application in visual studio 2010 in c#.
have created connection string file store connection string entered user in 1 of forms.
want software, automatically detect server name of sql server database installed on client's pc, , start working on specific database.
possible?
if yes can give code same integrate software, instead of connection string.
want the code written in program.cs file only, , on every form makes connection.
thank you.

hi varij,

it's practice server name + connection string config file.

however if have specific request detect server name code there no direct way while installation user can select server name. still assuming sqlserver installed default setting , windows authentication. can try connecting database server name mssqlserver.

there other ways getting name of services running on system & extracting server name service name. still recommending store connection string in configuration file..

hope helps...

rajat.



Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

Catalog Staging

How to Share webservice object to all user