S
SoftwareEngineerSince2014
Guest
I have a database name: Project_Management,
with table name: Employee_Registration,
I have designed a form with some basic information fields.
I have connected the form with SQL Express 2005 with Connection String: PMConnectionString,
I am getting error with this name 'Null Reference Exception was unhandled'
this is my button code:
private void SaveButton_Click(object sender, EventArgs e)
{
string constr = ConfigurationManager.ConnectionStrings["PMConnectionString"].ConnectionString;
SqlConnection connection = new SqlConnection(constr);
connection.Open();
string querytext = "INSERT into Employee_Registration (First_name,Last_Name,NIC_Number,DOB,Cell_Number,Designation,Address,Gender,Email) VALUES ('" + FNtxt.Text + "', '" + LNtxt.Text + "','" + NICtxt.Text + "','" + DOBtxt.Text + "','" + CellNumbertxt.Text + "','" + Designationtxt.Text + "','" + Addresstxt.Text + "','" + GenderDropdown.Text + "','" + emailtxt.Text + "') ";
SqlCommand cmd1 = new SqlCommand(querytext, connection);
cmd1.ExecuteNonQuery();
connection.Close();
}
Kindly Help!
Thank you!
Continue reading...
with table name: Employee_Registration,
I have designed a form with some basic information fields.
I have connected the form with SQL Express 2005 with Connection String: PMConnectionString,
I am getting error with this name 'Null Reference Exception was unhandled'
this is my button code:
private void SaveButton_Click(object sender, EventArgs e)
{
string constr = ConfigurationManager.ConnectionStrings["PMConnectionString"].ConnectionString;
SqlConnection connection = new SqlConnection(constr);
connection.Open();
string querytext = "INSERT into Employee_Registration (First_name,Last_Name,NIC_Number,DOB,Cell_Number,Designation,Address,Gender,Email) VALUES ('" + FNtxt.Text + "', '" + LNtxt.Text + "','" + NICtxt.Text + "','" + DOBtxt.Text + "','" + CellNumbertxt.Text + "','" + Designationtxt.Text + "','" + Addresstxt.Text + "','" + GenderDropdown.Text + "','" + emailtxt.Text + "') ";
SqlCommand cmd1 = new SqlCommand(querytext, connection);
cmd1.ExecuteNonQuery();
connection.Close();
}
Kindly Help!
Thank you!
Continue reading...