更新查询成功后如何获取Back消息? [英] how to get a Back message when an Update Query Successful ?

查看:84
本文介绍了更新查询成功后如何获取Back消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表格,其中包含客户信息和一些订单信息

当用户更改某些内容时

并按更新

两个单独的功能调用

updclient();

updorder();

i只想显示一个消息框显示更新成功



有没有办法检查两个更新状态并只显示一个MessageBox?

目前我正在使用这种方法

updorder ()

  int  a = adapter.InsertCommand.ExecuteNonQuery(); 
cmd.Connection.Close();
if (a == updatecheck)
{
stmessage.Text = 更新成功......;
}



updclient()

 SqlDataAdapter adapter = new SqlDataAdapter(); 
adapter.InsertCommand = cmd;
updatecheck = adapter.InsertCommand.ExecuteNonQuery(); // updatechecked Globle veriale
cmd.Connection。关闭();



第一个updclient()调用哪个fill updatecheck变量带有返回值

second updorder()调用用updatecheck检查了他的一个变量vertable

解决方案

当然你可以在int变量的帮助下做到这一点,当我们调用这个函数时必须返回int类型的值,像这样看到我的代码片段

 更新 TableName  set  名称=( 希望   update 其中 名称=条件



W在

的帮助下执行此查询ExecuteNonQuery()

必须返回int类型的值,如1或0.我希望你理解我在我的行中尝试的内容。

点击重播任何查询或问题。



快乐编码

jsb


< blockquote>对于 UPDATE,INSERT和DELETE 语句,返回值是受影响的行数命令



因此你应该在方法中插入相等的行数,那么只有条件才会满足。


i have a Form that has Client Information and some Order Information
when user Change some thing
and press Update
two separate Function called
updclient();
updorder();
i want to show only one Message Box showing that "update Successfull"

is there any way to check both updates status and show only one MessageBox ?
Currently i am using this method
updorder()

int a=adapter.InsertCommand.ExecuteNonQuery();
                cmd.Connection.Close();
                if (a == updatecheck)
                {
                    stmessage.Text = "Update Successfull...";
                }


updclient()

SqlDataAdapter adapter = new SqlDataAdapter();
                adapter.InsertCommand = cmd;
                updatecheck = adapter.InsertCommand.ExecuteNonQuery();//updatechecked is Globle veriale
                cmd.Connection.Close();


first updclient() called which fill updatecheck variable with return value
second updorder() called which checked his a variable with updatecheck veriable

解决方案

off course you can do this with the help of int variable, when we call this function must be return int type of value, like this see my snippet code

Update TableName set column Name=(Value of want to update) where column Name=Condition


When execute this query with help of

ExecuteNonQuery()

Must be Return int type of Value like that 1 or 0. I hope you understand what i trying in my line.
hit to replay for any query or problem.

Happy coding
jsb


For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command

so you should insert equal no of rows in both the method, then only the condition will satisfy.


这篇关于更新查询成功后如何获取Back消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆