TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Cj Mah
NA
0
2k
EditStaff got input string problem
Dec 29 2015 7:19 AM
i got the error message:
Input string was not in a correct format. I cannot find the error.
string staffId = null;
SqlConnection conn = null;
SqlCommand cmd = null;
string connectionString = null;
protected void btnSubmit_Click(object sender, EventArgs e)
{
connectionString = ConfigurationManager.ConnectionStrings["FacilityCS"].ConnectionString;
conn = new SqlConnection(connectionString);
string sql = "UPDATE Staff SET StaffId=@staffId, Password=@password, StaffName=@staffName,";
sql+=" Email=@email, PhoneNo=@phoneNo, Title=@title, Role=@role";
try
{
cmd = new SqlCommand(sql, conn);
cmd.Parameters.AddWithValue("@staffId", tbStaffId.Text);
cmd.Parameters.AddWithValue("@password", tbPassword.Text);
cmd.Parameters.AddWithValue("@staffName", tbStaffName.Text);
cmd.Parameters.AddWithValue("@email", tbEmail.Text);
cmd.Parameters.AddWithValue("@phoneNo", tbPhoneNo.Text);
cmd.Parameters.AddWithValue("@title", Convert.ToInt32(ddlTitle.SelectedValue));
cmd.Parameters.AddWithValue("@role", Convert.ToInt32(rbRole.SelectedValue));
conn.Open();
int row = cmd.ExecuteNonQuery();
if(row>0)
{
lblOutput.Text = "Record Updated successfully";
}
}
catch(Exception ex)
{
lblOutput.Text = "Error Message: " + ex.Message;
}
finally
{
if (conn != null)
conn.Close();
}
}
Reply
Answers (
3
)
hidden field validation
Error->Invalid length for a Base-64 char array