Click here to Skip to main content
15,908,274 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello
I want a program that works like sql server service manager.
How to do find name server on the system?
How to do attach a data base on the server?
Posted
Comments
Sandeep Mewara 7-Jan-11 3:46am    
Not clear.

You can find the server instances with this function:

DataTable _dtServers = SqlDataSourceEnumerator.Instance.GetDataSources();



And you can attach a DataBase with this code:

XML
CREATE DATABASE database_name
    ON <filespec> [ ,...n ]
    FOR { ATTACH [ WITH <service_broker_option> ]
        | ATTACH_REBUILD_LOG }
[;]


You can find more information about it here: CLICK
 
Share this answer
 
Comments
Dalek Dave 7-Jan-11 3:54am    
Good Answer.
fjdiewornncalwe 7-Jan-11 10:32am    
+5. The best way I know of as well.
BTW your question is not clear. From my understanding i have given you the link below. Check it out.

Hope This[^] will help you.
 
Share this answer
 
Comments
fjdiewornncalwe 7-Jan-11 10:31am    
Sorry, but he needs to do this from C# so that is can run from his application.
How to do find name server on the system?

whenever you will entered the sqlserver then, sqlserver will display the server name.

How to do attach a data base on the server?

Use the statement of CREATE DATABASE fn.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900