Firstly I have created a console application, and from within that application I have created a simple 1 table database and added two rows of data. So I now the database is there and working.
Problem is I keep getting the following error which trying to apply a connection string to an SQLConnection object:
Message: "ExecuteReader requires an open and available Connection. The connection's current state is closed."
The code I am using is as follows:
strSQLConnection = "Data Source=.\SQLEXPRESS;AttachDbFilename=" + Chr(34) + _
My.Computer.FileSystem.CurrentDirectory.ToString() + "\MusicManager.mdf" + Chr(34) + _
";Integrated Security=True;User Instance=True"
Try
conn.ConnectionString = strSQLConnection
...
...
I know the file exists and is in the right location. Why won't SQL Express open the database
I have successfully created Windows Applications that can connect to a database. What am I doing wrong
Cheers,
Roy

Connecting To SQLExpress From a VB Console Application
JohnsonZhang
Uriel
CHowell
That was it. Thanks.
How I missed that I do not know...
Roy
victoriak68
Pablo Castro
Program Manager - ADO.NET Team
Microsoft Corp.