检查表中是否存在数据 [英] check whether data exists in table

查看:81
本文介绍了检查表中是否存在数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有logout.aspx页,当有人单击注销时,它将在数据库中检查用户是否输入了时间,否则将引发错误.

我想要使​​用javascript进行SQL查询.

有人可以帮我吗.

Hi
I have logout.aspx page in which when someone clicks the logout then it will check in database whether time is entered by the user and if not it will throw an error.

I want sql query for this using javascript.

can somebody help me in this.

推荐答案

嗨 您无法通过javascript调用sql查询.您可以通过 Jquery Ajax 调用网络方法来执行此操作,并从那个.

例如,
Hi you can not call sql query from javascript..You can do this by calling web method from Jquery Ajax and get response from that.

for example,


.ajax({ 类型:" , url:" , 数据:" , contentType:" , dataType:" , 成功:功能(msg){ // 将div的内容替换为page方法的返回值. 警报(msg.d); } });
.ajax({ type: "POST", url: "WebService.aspx/CheckLogout", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg) { // Replace the div's content with the page method's return. alert(msg.d); } });


在WebService.aspx页中创建CheckLogout 网络方法,然后返回结果


Create a CheckLogout web method in WebService.aspx page and return result

[System.Web.Services.WebMethod]
public static String CheckLogout()
{
   // return result
}


这篇关于检查表中是否存在数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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