Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. how to connect to default instance of SQL Server?

how to connect to default instance of SQL Server?

Scheduled Pinned Locked Moved C#
databasesql-serversysadminsecuritytutorial
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bouli
    wrote on last edited by
    #1

    Hello gurus, I'd like to know how I can get connected to the default instance of SQL Server with user login? Where can I find a code snipet that shows how to do that with Windows authentication and SQL Server authentication? Best regards. Fred.

    There is no spoon.

    C A R 3 Replies Last reply
    0
    • B bouli

      Hello gurus, I'd like to know how I can get connected to the default instance of SQL Server with user login? Where can I find a code snipet that shows how to do that with Windows authentication and SQL Server authentication? Best regards. Fred.

      There is no spoon.

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      bouli wrote:

      I'd like to know how I can get connected to the default instance of SQL Server with user login?

      By just specifying the machine name, without any instance part. You can find lots of examples of connection strings for SQL Server here: http://www.connectionstrings.com/?carrier=sqlserver[^]


      Upcoming events: * Glasgow Geek Dinner (5th March) * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos

      1 Reply Last reply
      0
      • B bouli

        Hello gurus, I'd like to know how I can get connected to the default instance of SQL Server with user login? Where can I find a code snipet that shows how to do that with Windows authentication and SQL Server authentication? Best regards. Fred.

        There is no spoon.

        A Offline
        A Offline
        Aaron VanWieren
        wrote on last edited by
        #3

        Also, if you just want some examples related to your local databases you could look at the connection string that is located in the properties dialog when you select a database server in the server viewer section of VS2005. Aaron

        _____________________________________________________________________ Our developers never release code. Rather, it tends to escape, pillaging the countryside all around. The Enlightenment Project (paraphrased comment) Visit Me at GISDevCafe

        1 Reply Last reply
        0
        • B bouli

          Hello gurus, I'd like to know how I can get connected to the default instance of SQL Server with user login? Where can I find a code snipet that shows how to do that with Windows authentication and SQL Server authentication? Best regards. Fred.

          There is no spoon.

          R Offline
          R Offline
          Ryno Burger
          wrote on last edited by
          #4

          This should get you started. try { SqlConnection connection = new SqlConnection("server=localhost; database=yourdb; user=yourusername; password=yourpassword); connection.Open(); } catch (SQLExcepton SqlE) { //Do you exception handling here connection.Close(); } Remember, you need to include the System.Data.Sql namespace for this

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups