.NET 2008中的数据库连接 [英] database connectivity in .net 2008
本文介绍了.NET 2008中的数据库连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将如何在登录页面建立连接
登录页面包含-
login_id .........
passward .........
how will i make connection in login page
login page contain-
login_id.........
passward.........
推荐答案
请尝试以下操作.
please try the following.
using System.Data.SqlClient;
using system.Data;
关于按钮的点击事件,请写
on click event of button please write
sqlconnection conn=new Sqlconnection("Your Connection String");
if(conn.state.equals(connectionstate.closed)
conn.open();
sqlcommand cmd=new sqlcommand("SELECT COUNT(ID) FROM table_name where Log_in=''"+login_id+"'' AND password=''"+Password+"''",conn);
sqldataadapter da=new sqldataadapter(cmd);
if(cmd.executeNonQuery()>0)
response.write("<script>alert(''valid user'')</script>");
else
response.write("<script>alert(''Invalid user'')</script>");
我假设您的字段是主键.用sqlcommand的table_name替换表的名称.
i assumes that your field is primary key.replace the name of table with table_name of sqlcommand.
这篇关于.NET 2008中的数据库连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文