is there any way to get the SQL Server Name using the Visual Studio .Net 2005 c#,
i want to connect to sql server 2000 on host which is not my PC and id like to know its name
can i ?
thx alot
Printable View
is there any way to get the SQL Server Name using the Visual Studio .Net 2005 c#,
i want to connect to sql server 2000 on host which is not my PC and id like to know its name
can i ?
thx alot
That code is from a VB project of mine but I'm sure you can convert it to C# easily enough. Add a reference to SQLDMO from the COM tab.vb Code:
Dim dmo As New SQLDMO.Application 'List all available SQL Servers in the Server field. For Each server As String In dmo.ListAvailableSQLServers() Me.serverCombo.Items.Add(server) Next server
k thanks alot i will try to use this
or something like that in the c#
jmcilhinney, hi i was thinking that your code will work fine
well, i think there is som thing i missed but i dont know so i wish you can help me,
this is the error message i get
Code:Unable to cast COM object of type 'System.__ComObject' to
interface type 'SQLDMO.NameList'. This operation failed because the
QueryInterface call on the COM component for the interface with IID '{
10022406-E260-11CF-AE68-00AA004A34D5}' failed due to the following
error: No such interface supported (Exception from HRESULT: 0x80004002
(E_NOINTERFACE)).
i found some thin about the sql sever 2000 sp2 and the casting Error prob
if i get it installed on my pc would this help me to solve my prob?
thax alot
SP4 has been released for SQL Server 2000. You should be running the most up-to-date version. I can't guarantee that that will fix your issue but you should apply all service packs anyway.