Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Cannot open database "northwind" requested by the

Author  Topic 

ECRSoftware
Starting Member

1 Post

Posted - 2008-02-15 : 02:33:57
Hi there. Im new to working with SQL Servers, so please be patient. I recently downloaded some samples of connecting to SQL Servers using VB.net. Problem is I cannot connect to the server. I get an error "Cannot open database "northwind" requested by the login. The login failed"

I can connect to the database no problem using SQL Service Management Studios (SQL2005), so I think the problem lies either with the setup of the PC im using (security), or perhaps it cannot find the database. The code Im using is as follows

Dim DS As DataSet
Dim MyConnection As SqlConnection
Dim MyCommand As SqlDataAdapter
MyConnection = New SqlConnection("Trusted_Connection=yes;server=.\sqlexpress;Integrated Security=SSPI;uid=sa;pwd=;database=northwind")
MyCommand = New SqlDataAdapter("select firstname as 'First Name', lastname as 'Last Name' Title from Employees", MyConnection)
DS = New DataSet("Employees")
MyCommand.Fill(DS) 'This is where the error occurs
grdEmployees.DataSource = DS
grdEmployees.DataBind()

I've been reading up on this problem for a week but with no luck.

PLEASE HELP !

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-02-15 : 04:33:28
Which is it?
Trusted connection/SSPI or useraccount SA with empty password?
Make your mind up.

www.connectionstrings.com



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-02-15 : 04:37:05
You also need to choose provider for your connection.

Provider=SQLNCLI;Server=.\sqlexpress;Database=northwind;Trusted_Connection=yes;
Provider=SQLNCLI;Server=.\sqlexpress;Database=northwind;Uid=sa;Pwd=;



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -