Click here to Skip to main content
12,064,498 members (49,004 online)
   

C#

 
GeneralRe: Error Pin
NaNg1524111-Feb-06 9:13
memberNaNg1524111-Feb-06 9:13 
GeneralRe: Error Pin
NaNg1524111-Feb-06 10:36
memberNaNg1524111-Feb-06 10:36 
GeneralRe: Error Pin
perlmunger11-Feb-06 12:09
memberperlmunger11-Feb-06 12:09 
QuestionCreate list with Grid and getting Process info in C#. Pin
yanshof11-Feb-06 2:37
memberyanshof11-Feb-06 2:37 
AnswerSome one can help me with this question please ? Pin
yanshof11-Feb-06 10:02
memberyanshof11-Feb-06 10:02 
AnswerRe: Create list with Grid and getting Process info in C#. Pin
Dave Kreskowiak11-Feb-06 11:51
memberDave Kreskowiak11-Feb-06 11:51 
QuestionHow to browse SQL server from a network? Pin
bouli10-Feb-06 22:46
memberbouli10-Feb-06 22:46 
AnswerRe: How to browse SQL server from a network? Pin
perlmunger11-Feb-06 7:34
memberperlmunger11-Feb-06 7:34 
You don't mention if you are using SQL Server 2000 or 2005. I'll assume 2000 because I can provide you with an answer (though I would be surprised if the answer was much different in 2005).

You need to use SQLDMO. This is a COM component that allows you to programmatically control SQL Server. Here is a basic snippet for loading a list of servers:
ArrayList serverList = new ArrayList();
SQLDMO.Application dmo = new SQLDMO.Application();
SQLDMO.NameList nameList;
nameList=dmo.ListAvailableSQLServers();
foreach ( object svrName in nameList)
{
	string server = svrName.ToString();
	if (server == "(local)")
	{
		server = "localhost" ;
	}
	serverList.Add ( server ) ;
}
The section where I check to see if the current server name is (local) and then change it to localhost is there because if you provide (local) in your connection string, it won't work properly. It expects localhost.

You can now use the ArrayList serverList in a listview or a combobox. In order to use SQLDMO, you will need to add a reference to it. Just right-click and "Add Reference" on the references folder in your project. Then click the COM tab in the ensuing dialog. Search through that list for "Microsoft SQLDMO Object Library". Click Select and then Ok. Visual studio will automatically make a .NET wrapper for the object and you should be able to use it as I have specified in my code above (though the SQLDMO namespace may come up as something different in yours. Just look at the references list once it's been added to know if you need to alter that in your code).

Let me know if you have any questions.

-Matt

------------------------------------------

The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
QuestionI need Help Pin
BestArtemis10-Feb-06 22:22
memberBestArtemis10-Feb-06 22:22 
AnswerRe: I need Help Pin
Wayne Phipps10-Feb-06 22:35
memberWayne Phipps10-Feb-06 22:35 
QuestionDLL Problem Pin
ExpertComing10-Feb-06 15:06
memberExpertComing10-Feb-06 15:06 
AnswerRe: DLL Problem Pin
Dave Kreskowiak10-Feb-06 15:28
memberDave Kreskowiak10-Feb-06 15:28 
GeneralRe: DLL Problem (How?) Pin
ExpertComing10-Feb-06 15:33
memberExpertComing10-Feb-06 15:33 
GeneralRe: DLL Problem (How?) Pin
Dave Kreskowiak10-Feb-06 15:56
memberDave Kreskowiak10-Feb-06 15:56 
GeneralRe: DLL Problem (How?) Pin
kourvoisier10-Feb-06 15:59
memberkourvoisier10-Feb-06 15:59 
GeneralRe: DLL Problem (How?) Pin
ExpertComing10-Feb-06 16:09
memberExpertComing10-Feb-06 16:09 
GeneralRe: DLL Problem (How?) Pin
Dave Kreskowiak10-Feb-06 17:50
memberDave Kreskowiak10-Feb-06 17:50 
GeneralRe: DLL Problem (How?) Pin
ExpertComing10-Feb-06 18:09
memberExpertComing10-Feb-06 18:09 
GeneralRe: DLL Problem (How?) Pin
Dave Kreskowiak10-Feb-06 18:25
memberDave Kreskowiak10-Feb-06 18:25 
GeneralRe: DLL Problem (How?) Pin
ExpertComing10-Feb-06 18:32
memberExpertComing10-Feb-06 18:32 
Question2 question about C#.... Pin
yanshof10-Feb-06 13:37
memberyanshof10-Feb-06 13:37 
AnswerRe: 2 question about C#.... Pin
ExpertComing10-Feb-06 14:03
memberExpertComing10-Feb-06 14:03 
AnswerRe: 2 question about C#.... Pin
Sean8910-Feb-06 14:16
memberSean8910-Feb-06 14:16 
AnswerRe: 2 question about C#.... Pin
perlmunger10-Feb-06 19:14
memberperlmunger10-Feb-06 19:14 
QuestionDrawing with c# Pin
kourvoisier10-Feb-06 13:29
memberkourvoisier10-Feb-06 13:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web02 | 2.8.160204.4 | Last Updated 6 Feb 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid