如何在单按钮单击事件上编写插入更新查询 [英] how to posssible to write insert update query on single button click event

查看:85
本文介绍了如何在单按钮单击事件上编写插入更新查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在单按钮单击事件上编写插入更新查询

how to posssible to write insert update query on single button click event

推荐答案

您将需要主键进行记录..检查是否已存在(首先选择匹配记录,如果计数> 1,则更新,否则插入...
you will need primary key for record..check if already exists(by first selecting matching record,if count >1 then update ,else insert ...




很忙,所以无法回复.

还有问题吗?

使用以下逻辑

在存储过程中

取得可从数据库中检索唯一记录的参数.电子邮件ID或手机号码,如

1.从过程参数中,选择带有ID的选择查询(返回的主键类似)
声明ID;
从学生中选择@ id = id,其中email_id = @ email_id

2.检查id是否存在,如果为id,则为更新,否则为insert

if(@ id> 1)
更新
其他
插入

希望这可以澄清您
Hi,

Was busy so couldnot reply.

Still has problem ?

Use following logic

In stored procedure

Take parameter that will retrive unique records from Database.e.g. Email Id or Mobile Number like

1. from procedure parameter,fire select query with id (primary key returned like )
declare id;
select @id=id from students where email_id=@email_id

2. check if id exists ,if it is then it is update else it is insert

if(@id>1)
update
else
insert

Hope this clarifies you


提示 [ ^ ]可以帮助您了解如何通过存储过程来完成它.
This tip[^] may help you to understand how it can be done via stored procedure.


这篇关于如何在单按钮单击事件上编写插入更新查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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