Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void UpdateCheckboxValueOfIndexPage(string userName,string checkboxValue, string checkedValue)
- {
- SqlConnection connection=new SqlConnection(connectionString);
- try
- {
- string updateQuery = "UPDATE UserChoiceTable SET Checked=@Checked WHERE UserName=@UserName AND CheckBoxValue=@CheckBoxValue";
- SqlCommand command = new SqlCommand(updateQuery, connection);
- command.Parameters.Clear();
- command.Parameters.Add("UserName", SqlDbType.VarChar);
- command.Parameters["UserName"].Value = userName;
- command.Parameters.Add("CheckBoxValue", SqlDbType.VarChar);
- command.Parameters["CheckBoxValue"].Value = checkboxValue;
- command.Parameters.Add("Checked", SqlDbType.VarChar);
- command.Parameters["Checked"].Value = checkedValue;
- connection.Open();
- int rowAffected = command.ExecuteNonQuery();
- connection.Close();
- }
- catch (Exception ex)
- {
- }
- }
- public string CheckBoxChecked(string userName, string checkBoxValue)
- {
- string Ischecked = null;
- SqlConnection connection = new SqlConnection(connectionString);
- try
- {
- string query = "SELECT * FROM UserChoiceTable WHERE UserName=@UserName AND CheckBoxValue=@CheckBoxValue";
- SqlCommand command = new SqlCommand(query, connection);
- command.Parameters.Clear();
- command.Parameters.Add("UserName", SqlDbType.VarChar);
- command.Parameters["UserName"].Value = userName;
- command.Parameters.Add("CheckBoxValue", SqlDbType.VarChar);
- command.Parameters["CheckBoxValue"].Value = checkBoxValue;
- connection.Open();
- SqlDataReader reader = command.ExecuteReader();
- if (reader.Read())
- {
- Ischecked = reader["Checked"].ToString();
- }
- return Ischecked;
- }
- catch (Exception ex)
- {
- return Ischecked = null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement