I'm not sure why I'm getting the error:
An exception of type 'System.Data.SqlClient.SqlException' occurred in
System.Data.dll but was not handled in user code
Additional information: String or binary data would be truncated.
My code is:
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
conn.Open();
cmd.CommandText = "SELECT MAX(EmpID) FROM EmpInfo";
SqlDataReader rdr = cmd.ExecuteReader();
rdr.Close();
// cmd.CommandText = "INSERT INTO EmpInfo(EmpYear,EmpStatus,LName,FName,JobTitle,EmpPay,EmpDoB,EmpSex,EmpAddr,EmpCity,EmpState,EmpZIP,EmpCountry,EmpEAddr,EmpTelNo,EmpMobileNo) values('" + EmpYear + "', 'Active', '" + regLname_text.Text + "', '" + regFname_text.Text + "', 'NULL', '" + PayType_cb.SelectedItem.ToString() + "', '" + regDob_dtp.Value.Date + "', '" + gender + "', '" + regAddr_text.Text + "', '" + regCity_text.Text + "', '" + regState_text.Text + "', '" + regZip_text.Text + "', '" + regCountry_text.Text + "', '" + regEmail_text + "', '" + regTel_text.Text + "', '" + regMob_text.Text + "')";
cmd.CommandText = "INSERT INTO EmpInfo(EmpYear,EmpStatus,LName,FName,JobTitle,EmpPay,EmpDoB,EmpSex,EmpAddr,EmpCity,EmpState,EmpZIP,EmpCountry,EmpEAddr,EmpTelNo,EmpMobileNo) values('" + EmpYear + "', 'Active', '" + regLname_text.Text + "', '" + regFname_text.Text + "', 'NULL', '" + PayType_cb.SelectedItem.ToString() + "', '" + regDob_dtp.Value.Date + "', '" + gender + "', '" + regAddr_text.Text + "', '" + regCity_text.Text + "', '" + regState_text.Text + "', '" + regZip_text.Text + "', '" + regCountry_text.Text + "', '" + regEmail_text + "', '" + regTel_text.Text + "', '" + regMob_text.Text + "')";
cmd.ExecuteNonQuery();
cmd.CommandText = "INSERT INTO AccountInfo(LName, FName, EmpTemplate,AccountType,EmpStatus) VALUES('" + regLname_text.Text + "','" + regFname_text.Text + "','" + template + "','" + AcctType_cb.SelectedItem.ToString() + "','Active')";
cmd.ExecuteNonQuery();
Your assistance is greatly appreciated, thank you.