0
try
        {
            UserMaster ObjUserMst = new UserMaster();
            ObjUserMst.GetData("UPDATE  MemberDetails SET Active = 0  WHERE Member_No = '" + txtmemberno.Text + "'");
            MessageBox.Show("Installment Close Successfully.", "Close Installment", MessageBoxButtons.OK, MessageBoxIcon.Information);
            btndebit.Visible = true;
            btndebit.Visible = false;
        }
        catch (Exception ex)
        {
            XtraMessageBox.Show(ex.Message.ToString(), "btncloseinstallment_Click", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }

its get data code

public DataTable GetData(string Query)
    {


        string cn = GlobalClass.ConnectionStringGet();
        Con = new SqlConnection(cn);
        cmd = new SqlCommand();
        cmd.Connection = Con;
        if (cmd.Connection.State == ConnectionState.Closed)
        {
            cmd.Connection.Open();
        }
        SqlTransaction ObjTrans = cmd.Connection.BeginTransaction();
        cmd.Transaction = ObjTrans;
        cmd.CommandType = CommandType.Text;
        cmd.CommandText = Query;
        cmd.CommandTimeout = 500;

        SqlDataReader dreader = cmd.ExecuteReader();
        DataTable dt = new DataTable();
        dt.Load(dreader);
        Con.Close();
        Con.Dispose();
        return dt;

    }

i have winforms.
i have memberdetails Table - in this Active Field & its datatype is BIT.
its default value is 1. but i need to update it to 0.
1 = ture
0 = false
when i tried above code Active Field data didnt update
but i got message "Installment Close Successfully."
https://i.sstatic.net/mkuhW.png
https://i.sstatic.net/ToXFV.png
I upload my images on above link

help me guys.. sorry if i didnt explain very well bcz i m new here

4
  • So no exception is being thrown and its successful? Commented Sep 19, 2015 at 19:48
  • ya but i think its just given message without update. Commented Sep 19, 2015 at 19:54
  • SQL Injection alert - you should not concatenate together your SQL statements - use parametrized queries instead to avoid SQL injection Commented Sep 19, 2015 at 22:16
  • @AlpeshSavaliya Although you said you got it, but I strongly recommend you to read my answer and hope you find it helpful :) Commented Sep 20, 2015 at 12:48

1 Answer 1

1

ok i got it.

        string constring = GlobalClass.ConnectionStringGet();
        string sqlUpdate = "UPDATE  MemberDetails SET Active = '0'  WHERE Member_No = '" + txtmemberno.Text + "'";
        SqlConnection conDatabase = new SqlConnection(constring);
        SqlCommand cmdd = new SqlCommand(sqlUpdate, conDatabase);
        conDatabase.Open();
        cmdd.ExecuteNonQuery();
        conDatabase.Close();

        MessageBox.Show("Installment Close Successfully.");


its update Active Field 1 to 0 successfully.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.