I am trying to establish a connection between asp.net and sql server using C# connection string but it shows error that the file name is not specified
My code is like this:
SqlConnection con = new SqlConnection("data source=MYserver;initial catalog=master;integrated security=true");
con.Open();
SqlCommand cmd = new SqlCommand("insert into sqldb values("+textBox1.Text+",'"+ textBox2.Text+"',"+textBox3.Text+",'"+textBox4.Text+"')",con);
cmd.ExecuteNonQuery();
con.Close();
con.Close();
Help me in solving the problem
Thanks

Satyapriya NayakRank #47 · 31.5K reputationPosted May 21, 2013, 10:27 PM EDT
Sunny SharmaRank #223 · 11.1K reputationPosted May 21, 2013, 10:34 PM EDT
As the error says, you really are missing a file name in your connection string. Here is a sample connection string:
connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=myTable;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\mySampleDB.mdf" providerName="System.Data.SqlClient" Please see the highlighted parameter and update your code in order to get it working. Hope it helps!