|
-
Apr 14th, 2011, 03:37 PM
#1
Thread Starter
Lively Member
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
-
Apr 14th, 2011, 04:39 PM
#2
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")
-
Apr 15th, 2011, 04:02 PM
#3
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|