×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Update data in TextChanged event show message when retrieve data or show data

Update data in TextChanged event show message when retrieve data or show data

Update data in TextChanged event show message when retrieve data or show data

(OP)
Hi guys I need to show message "record successfully updated" when i updated database only not every time
i retrieve data or show data
private void Driver_Load(object sender, EventArgs e)
{
string constr = "Data Source=" + value1 + ";Initial Catalog=" + value2 + ";User ID=" + value3 + ";Password=" + value4 + "";
con = new SqlConnection(constr);
string comdstr = "select * from Driver";
da = new SqlDataAdapter(comdstr, constr);
ds = new DataSet();
da.Fill(ds, "Driver");
dt = new DataTable();
dt = ds.Tables["Driver"];

totalrecord = dt.Rows.Count;


if (ds != null)
{
dt = ds.Tables[0];

currrecord = 0;
}
fillcontrol();
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
FleetManagment.Fleet fleet1 = new FleetManagment.Fleet();
int a = fleet1.UpdateDriver("Data Source=" + value1 + ";Initial Catalog=" + value2 + ";User ID=" + value3 + ";Password=" + value4 + "", Convert.ToInt32(textBox1.Text), textBox2.Text, textBox3.Text, textBox4.Text);
if (a>0)
{
message box.show("record successfully updated");
}
My code above working without any problem
But my problem why message box.show("record successfully updated")
display in every time i retrieve data or showing data
the screen shoot problem found in this link below :
https://www.mediafire.com/?9irjmtmrktmy9mc
as rar file
Thanks

RE: Update data in TextChanged event show message when retrieve data or show data

What I usually do in this situation is create a Boolean "flag" that is a protected variable in the class. In your case I'll call this variable "bLoading" and assume it's set to false in its declaration. I would then change your code to something like this:

CODE

private void Driver_Load(object sender, EventArgs e)
{
  bLoading = true;
  string constr = "Data Source=" + value1 + ";Initial Catalog=" + value2 + ";User ID=" + value3 + ";Password=" + value4 + "";
  con = new SqlConnection(constr);
  string comdstr = "select * from Driver";
  da = new SqlDataAdapter(comdstr, constr);
  ds = new DataSet();
  da.Fill(ds, "Driver");
  dt = new DataTable();
  dt = ds.Tables["Driver"];
  totalrecord = dt.Rows.Count;
  if (ds != null)
  {
    dt = ds.Tables[0];
    currrecord = 0;
  }
  fillcontrol();
  bLoading = false;
}
 
private void textBox2_TextChanged(object sender, EventArgs e)
{
  if (!bLoading)
  {
    FleetManagment.Fleet fleet1 = new FleetManagment.Fleet();
    int a = fleet1.UpdateDriver("Data Source=" + value1 + ";Initial Catalog=" + value2 + ";User ID=" + value3 + ";Password=" + value4 + "", Convert.ToInt32(textBox1.Text), textBox2.Text, textBox3.Text, textBox4.Text);
    if (a>0)
    {
      message box.show("record successfully updated");
    }
  }
} 

-Dell

DecisionFirst Technologies - Seven-time SAP BusinessObjects Solution Partner of the Year
www.decisionfirst.com

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close