|
-
Sep 15th, 2009, 04:30 PM
#1
Thread Starter
Junior Member
problem with connection strings
Hi
I'm having problems with connection strings.
I'm running a copy of vb express 2008 on my local. I also have installed a copy of sql on my local pc ( the sql version that comes with vb express 2008).
I have written the following lines of code
Imports System.Data
Imports System.Data.SqlClient
Dim nwindConn As SqlConnection = New SqlConnection("Data Source=localhost;Integrated Security=SSPI;" & _
"Initial Catalog=northwnd")
nwindConn.Open()
the code compiles o.k but when i run it I get 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
Does anyone know what causing the error?
-
Sep 15th, 2009, 04:36 PM
#2
Re: problem with connection strings
Thread moved to 'Database Development' forum
It sounds like you are using SQL Server Express, in which case there is an instance name of SQLExpress, so you should add that:
Code:
"Data Source=localhost\SQLExpress;Integrated Security=SSPI;" & _
-
Sep 15th, 2009, 05:02 PM
#3
Thread Starter
Junior Member
Re: problem with connection strings
hi,
did what you suggested.
now i get a different error message
Cannot open database "northwind" requested by the login. The login failed. Login failed for user 'RAQIB-6D4CEC9C3\mohammed'.
do you know what causes this error?
-
Sep 15th, 2009, 08:53 PM
#4
Re: problem with connection strings
Was SQL Server Express installed under that user account or a different one? If it was a different one then that user account has probably not been added to the SQL Server Administrators group and will not be able to log in using Windows Security.
-
Sep 16th, 2009, 06:36 AM
#5
Re: problem with connection strings
Isn't NorthWind an Access database?
If so, then code for SQL Server (Imports System.Data.SqlClient
and
Dim nwindConn As SqlConnection = New SqlConnection("Data Source=localhost;Integrated Security=SSPI;" & _
"Initial Catalog=northwnd")
isn't going to work.
-
Sep 16th, 2009, 06:40 AM
#6
Re: problem with connection strings
I'm pretty sure that there is also a Northwind for SQL Server now, so that people who are 'upsizing' can directly compare features etc to what is available in Access.
-
Sep 16th, 2009, 07:59 AM
#7
Hyperactive Member
Re: problem with connection strings
Hello,
I haven't used express edition but could you clarify what I suspect is a spelling mistake:
Code:
Dim nwindConn As SqlConnection = New SqlConnection("Data Source=localhost;Integrated Security=SSPI;" & _
"Initial Catalog=northwnd")
Kind regards
Steve
-
Sep 18th, 2009, 05:32 PM
#8
Thread Starter
Junior Member
Re: problem with connection strings
Hi,
Threre are no accounts on my computer (When i start up the pc, there is no login prompt). I'm therefore assuming that the potential cause of the problem as suggested by jmcilhinney cannot be correct.
I'm also certain that the spelling of the northwind database is correct. I have double checked this.
Regards,
Kareem.
-
Sep 20th, 2009, 06:59 AM
#9
Re: problem with connection strings
Whenever you are using Windows, you are always using an account. It sounds like you have got it set up to automatically log in to a particular account when Windows starts.
Based on post #3, the account you are using is called "mohammed".
Open up "SQL Server Management Studio" (or the interface inside VB), and check in the Security section that the account is listed there.
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
|