Trouble connecting to northwind

gayamantra

New member
Joined
Sep 2, 2006
Messages
4
Programming Experience
Beginner
Hi,

I am new to VB and I am trying to create a simple program in VB.NET in VS.NET 2005. I am just trying to retrieve some details from the Products Table in the Northwind database. But i keep hitting the following error

"An attempt to attach an auto-named database for file C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\northwnd failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share."

when the code hits da.Fill(ds). Here is my full code. Pls help! :-(

Private Sub btnQuery_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnQuery.Click
Dim connString As String = "Data Source=.\SQLEXPRESS;" + _
"AttachDbFilename=" + "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\northwnd" + ";" + _
"Integrated Security=true;" + _
"User Instance=True;" + _
"Connect Timeout=30;"
Dim conn As New SqlConnection(connString)
Dim cmd As New SqlCommand("Select ProductID,ProductName from Products", conn)
Dim da As New SqlDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds)
dgResult.DataSource = ds
End Sub
 
your system isnt set to show file extensions..? i cant believe that any developer would have their system set that way, but you learn something new every day
 
Back
Top