finally i fixed this using connection string in Web.config file using an extra attribute providerName="System.Data.SqlClient"
so my web.config file looks like :
<configuration>
<connectionStrings>
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\studentdata.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
and connection in C# file looks like :
conn = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
con= new SqlConnection(conn);
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "Insert INTO class10(subject,chapter_name,chapter_number,excercise_number,url) VALUES ('" + DropDownList1.SelectedValue + "','" + ChapterBox.Text.Trim() + "','" + Chapter_NumberBox.Text.Trim() + "','" + TextBox1.Text.Trim() + "','" + TextBox2.Text.Trim() + "' )";
cmd.Connection = con;
con.Open();
int updt = cmd.ExecuteNonQuery();
con.Close();
but still i am not able to call connection directly from C# code behind file even using the providerName="System.Data.SqlClient"
below is what i am trying now: .
SqlConnection con = new SqlConnection();
con.ConnectionString = @"Data Source=admin-929c9b7ea\SQLEXPRESS;" + @"Initial Catalog=App_Data\studentdata.mdf;" + @"Integrated Security=SSPI;" + @"providerName=System.Data.SqlClient";
If somebody can help on this that how can i use providername attribute in C# file directly....