Results 1 to 6 of 6

Thread: [2.0] getting SQL Server name?

  1. #1

    Thread Starter
    Frenzied Member avrail's Avatar
    Join Date
    Mar 2006
    Location
    Egypt, Cairo
    Posts
    1,221

    Question [2.0] getting SQL Server name?

    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
    Last edited by avrail; Mar 22nd, 2007 at 06:48 AM.
    You Don't Have to Rate Me.
    I'm Not a Civilized Man I'm the Civilization it self
    White or Black, Living or Dieing and 0 or 1 that's MY life
    iam an Object in Object Oriented Life
    my blog : http://refateid.blogspot.com/
    twitter :@avrail
    010011000111010101110110001000000100110101111001001000000101000001100011

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2.0] getting SQL Server name?

    vb Code:
    1. Dim dmo As New SQLDMO.Application
    2.  
    3. 'List all available SQL Servers in the Server field.
    4. For Each server As String In dmo.ListAvailableSQLServers()
    5.     Me.serverCombo.Items.Add(server)
    6. Next server
    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Frenzied Member avrail's Avatar
    Join Date
    Mar 2006
    Location
    Egypt, Cairo
    Posts
    1,221

    Re: [2.0] getting SQL Server name?

    k thanks alot i will try to use this
    or something like that in the c#
    You Don't Have to Rate Me.
    I'm Not a Civilized Man I'm the Civilization it self
    White or Black, Living or Dieing and 0 or 1 that's MY life
    iam an Object in Object Oriented Life
    my blog : http://refateid.blogspot.com/
    twitter :@avrail
    010011000111010101110110001000000100110101111001001000000101000001100011

  4. #4

    Thread Starter
    Frenzied Member avrail's Avatar
    Join Date
    Mar 2006
    Location
    Egypt, Cairo
    Posts
    1,221

    Re: [2.0] getting SQL Server name?

    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)).
    You Don't Have to Rate Me.
    I'm Not a Civilized Man I'm the Civilization it self
    White or Black, Living or Dieing and 0 or 1 that's MY life
    iam an Object in Object Oriented Life
    my blog : http://refateid.blogspot.com/
    twitter :@avrail
    010011000111010101110110001000000100110101111001001000000101000001100011

  5. #5

    Thread Starter
    Frenzied Member avrail's Avatar
    Join Date
    Mar 2006
    Location
    Egypt, Cairo
    Posts
    1,221

    Re: [2.0] getting SQL Server name?

    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
    Last edited by avrail; Apr 4th, 2007 at 06:24 PM.
    You Don't Have to Rate Me.
    I'm Not a Civilized Man I'm the Civilization it self
    White or Black, Living or Dieing and 0 or 1 that's MY life
    iam an Object in Object Oriented Life
    my blog : http://refateid.blogspot.com/
    twitter :@avrail
    010011000111010101110110001000000100110101111001001000000101000001100011

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2.0] getting SQL Server name?

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width