最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Jquery+asp.net 检测账号是否已被注册的实例代码
时间:2010-07-12 编辑:简简单单 来源:一聚教程网
jquery+asp教程.net 检测账号是否已被注册的实例代码
<%@ page language="c#" autoeventwireup="true" codebehind="default.aspx.cs" inherits="ajax_xml._default" %>
using system;
using system.collections.generic;
using system.linq;
using system.web;
using system.web.services;
using system.data;
using system.data.sqlclient;
using system.configuration;
using system.text;
using dal;
namespace ajax_xml
{
///
/// webservice1 的摘要说明
///
[webservice(namespace = "http://tempuri.org/")]
[webservicebinding(conformsto = wsiprofiles.basicprofile1_1)]
[system.componentmodel.toolboxitem(false)]
// 若要允许使用 asp.net教程 ajax 从脚本中调用此 web 服务,请取消对下行的注释。
[system.web.script.services.scriptservice]
public class webservice1 : system.web.services.webservice
{
[webmethod]
public string helloworld()
{
return "hello,world!";
}
[webmethod]
public string userisexist(string userid)
{
string sql = string.format("select * from customers where firstname='" + userid+"'");
using (sqldatareader dr = sqlhelper.executesql(sql))
{
if (dr.read())
return "false";
else
return "true";
}
}
}
}sqlheper.cs
using system;
using system.collections.generic;
using system.linq;
using system.text;
using system.data;
using system.data.sqlclient;
using system.configuration;
namespace dal
{
///
/// 数据库教程操作类
///
public class sqlhelper
{
private static sqlconnection conn;
private static sqlcommand comm;
private static sqldatareader dr;
///
/// 打开数据库连接
///
public static void connopen()
{
try
{
conn = new sqlconnection(configurationmanager.connectionstrings["bbs"].connectionstring);
conn.open();
}
catch (exception e)
{
console.writeline( e.message);
}
}
///
/// 关闭数据库连接,释放资源
///
public static void connclose()
{
if (conn != null)
{
conn.close();
}
if (comm != null)
{
comm.dispose();
}
}
public static sqldatareader executesql(string sql)
{
sqlhelper.connopen();
comm = new sqlcommand(sql, conn);
try
{
dr = comm.executereader();
return dr;
}
catch (exception e)
{
throw e;
}
}
}
}
-
上一个: asp.net生成静态页面代码
相关文章
- C#复制数组的两种方式及效率比较解读 10-24
- ASP.NET Identity用法解析 10-24
- ASP.NET MVC使用Identity增删改查用户介绍 10-24
- C语言中atoi函数模拟实现介绍 10-18
- .Net反向代理组件Yarp用法介绍 10-10
- .NET使用YARP通过编码方式配置域名转发实现反向代理教程 10-10