Well this i did the below to get the error, don't have a clue why the database connection fails.
Create a new ASP.NET Website
Add a new *.mdf database to App_Data
Add some tables to it using Server Explorer in Visual Studio
Right click DataBase and Copy Connection string. Insert it into WebConfig File like below
<connectionStrings> <add name="DB" connectionString="Data Source=.SQLEXPRESS;AttachDbFilename=C:inetpubwwwrootgsApp_Datadb.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/> </connectionStrings>
Add some code to get the data from
selectStatement = "select * from users"; SqlDataAdapter da = new SqlDataAdapter(selectStatement, ConfigurationManager.ConnectionStrings["DB"].ConnectionString); DataTable dtUsers = new DataTable(); da.Fill(dtUsers); GridView1.DataSource = dtUsers.DefaultView; GridView1.DataBind();
and zoot you get the error
See Question&Answers more detail:os