Establishsing database connection

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Vicky

    Establishsing database connection

    I have installed both SQL and visual studio 2005 in my computer having
    vista. I tried to establish the database connection using this code:

    SqlConnection conn = new SqlConnection(" data source= VICKY-PC//
    SQLEXPRESS; integrated security=yes;in itial
    catalog=master; Trusted_Connect ion=yes");
    conn.Open();

    But it is not working. It throws a run time error "An error has
    occurred while establishing a connection to the server. When
    connecting to SQL Server 2005, this failure may be caused by the fact
    that under the default settings SQL Server does not allow remote
    connections. (provider: Named Pipes Provider, error: 40 - Could not
    open a connection to SQL Server)"

    Can anyone tell me how to establish connection?? Plse give me brief
    description as i am a beginner...
  • Alberto Poblacion

    #2
    Re: Establishsing database connection

    "Vicky" <vicky87.eie@gm ail.comwrote in message
    news:f5a630bf-6be2-4d0e-ac5c-560354a27fdc@s2 0g2000prd.googl egroups.com...
    >I have installed both SQL and visual studio 2005 in my computer having
    vista. I tried to establish the database connection using this code:
    >
    SqlConnection conn = new SqlConnection(" data source= VICKY-PC//
    SQLEXPRESS; integrated security=yes;in itial
    catalog=master; Trusted_Connect ion=yes");
    conn.Open();
    >
    But it is not working. It throws a run time error "An error has
    occurred while establishing a connection to the server.
    The slash separating the server name from the instance name should be a
    backslash, rather than the two forward slashes that you entered. Of course,
    in the case of the backslash (but not the forward slash) you have to escape
    it, doubling it inside the string: "...VICKY-PC\\SQLEXPRESS. ..".


    Comment

    • Vicky

      #3
      Re: Establishsing database connection


      Thanks a lot Alberto... It's woking fine now :)

      Comment

      Working...