Results 1 to 3 of 3

Thread: connecting to a database

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2009
    Posts
    86

    connecting to a database

    Hi,

    I'm having problems connecting to a database. I have sql server 2005 express installed on my PC, and i am using the following to code to connect to it.

    Dim nwindConn As SqlConnection = New SqlConnection("Data Source=localhost\SQLExpress;Initial Catalog=northwnd;" & _
    "Integrated Security=SSPI")
    nwindConn.Open()
    nwindConn.Close()

    Every time i run the code it comes back with the error message " A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) "

    Regards,
    Kareem

  2. #2
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    Re: connecting to a database

    Try this minor fix first:

    Code:
    Dim nwindConn As SqlConnection = New SqlConnection("Data Source=localhost\SQLExpress;Initial Catalog=northwind;" & _
    "Integrated Security=SSPI")

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2009
    Posts
    86

    Re: connecting to a database

    Hi,

    The connection string in your reply is exactly the same as the one in my actual code.

    Northwnd was just a typing error I made whilst listing the problem on this forum.

    I have resolved the problem ( well sort of ) by using Oledbconnection intead of sqlconnection.

    But this causes further problems. Because I'm working with stored procedures I'm running into problems, and I keep getting a error message . I have been told using Oledbconnection with stored procedures won't work because "OleDb Provider for SQL Compact only implements a forward only cursor, so using it with Datasets are out of the question ".

    Is this correct, and is there a solution.

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