The ConnectionString property has not been initialized.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The ConnectionString property has not been initialized.
Source Error:
Line 43: cmd.Parameters.AddWithValue("@StudentName",txtName.Text);
Line 44: cmd.Parameters.AddWithValue("@Age",Convert.ToInt32(txtAge.Text));
Line 45: con.Open();
Line 46: int rows = cmd.ExecuteNonQuery();
Line 47: con.Close();
Source File: C:\Users\ajayb\source\repos\WebApplicationpract7c\WebApplicationpract7c\InsertDelete.aspx.cs Line: 45

Amit MohantyPosted Oct 3, 2025, 6:09 AM
Try this once:
Tuhin PaulPosted Oct 4, 2025, 2:48 AM
In your
Web.configfile (at the root of your project), add asection inside:In your
InsertDelete.aspx.csfile, do not hardcode or leave the connection empty. Instead, retrieve it fromWeb.config:Security & Best Practices
.csfiles.usingblocks to auto-dispose connections and commands.txtAge.Textis a number)