Question background:
I have developed a WinForm app and am now at the stage of wishing to publish it.
I have an SQL server database that I have added into a folder of the solution explorer as I want the database to be deployed within the app, as shown;
Within this DataSet I have a number of stored procedures added.
The issue:
When I debug the app, supplying the following connection string in the code snippet the DataGridView is not populated.
string connectionString = @"Data Source=.;Integrated Security=True;AttachDbFilename=|DataDirectory|\testDB.mdf";**
public override DataSet FillDataGrid()
{
SqlConnection connection = new SqlConnection(connectionString);
SqlDataAdapter dataadapter = new SqlDataAdapter("spListAll", connection);
DataSet ds = new DataSet();
connection.Open();
dataadapter.Fill(ds, "results");
connection.Close();
int size = ds.Tables[0].Rows.Count;
return ds;
}
If I supply the connection string from a Database stored locally on my machine with the connection string as follows, it works perfectly populating the grid.
string connectionString = @"Data Source=DAVE-PC\FINAWARE; Initial Catalog=testDB; Integrated Security=SSPI;";
Can anyone tell me how I should be correctly setting this up so I can use the testDB.mdf in the solution explorer folder?