Click to See Complete Forum and Search --> : [2.0] getting SQL Server name?
avrail
Mar 22nd, 2007, 06:22 AM
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
jmcilhinney
Mar 22nd, 2007, 09:27 PM
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 serverThat 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.
avrail
Mar 22nd, 2007, 09:30 PM
k thanks alot i will try to use this
or something like that in the c#
avrail
Apr 4th, 2007, 06:18 PM
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
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)).
avrail
Apr 4th, 2007, 06:18 PM
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
jmcilhinney
Apr 4th, 2007, 07:46 PM
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.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.