Loading...

java .net

2007年6月5日 星期二

装了个vs.net2005好些天了,今天做了个登录页面的练习,捣鼓了半天,又问人又查帮助的,呵呵,

using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
         protected void Page_Load(object sender, EventArgs e)
         {

         }
         protected void btnLogin_Click(object sender, EventArgs e)
         {
             string userName = this.tbUserName.Text;
             string pwd = this.tbPwd.Text;
             string sql = "select * from tb_user where id='" + userName + "' and passwd='" + pwd + "'";

             String url = ConfigurationManager.ConnectionStrings["csConnectionString"].ConnectionString;


             DataSet dataSet = new DataSet("user");
             using (SqlConnection connection = new SqlConnection(url))
             {
                 connection.Open();
                 SqlDataAdapter da = new SqlDataAdapter(sql, connection);
                 da.Fill(dataSet);
                 connection.Close();
             }

             if (dataSet.Tables[0].Rows.Count > 0)
             {
                 Response.Write("<script>alert('login success');</script>");
             }
             else
             {
                 Response.Write("<script>alert('login failed');</script>");
             }

         }
}

.net中数据适配器SqlDataAdapter 和数据集DataSet都不用关闭么?java中jdbc的Statement和ResultSet可都是要关的

终于捣鼓出来了

posted on 2008-08-26 22:06 阅读(84) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航:
 

公告

希望有一天

我能用鼠标双击我的钱包

然后选中一张100元

按住“ctrl+c”

接着不停的“ctrl+v”

嘻嘻~~~笑醒~~~



导航

<2008年8月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456

统计

常用链接

留言簿(6)

随笔分类(102)

随笔档案(398)

文章分类

文章档案(10)

有趣网络

搜索

积分与排名

最新评论

阅读排行榜

评论排行榜