ASP.NET连接Access数据库代码

来源:互联网 发布:p视频的软件 编辑:程序博客网 时间:2024/04/30 04:21

using System.Data.OleDb;

 

string ConnStr ="Provider=Microsoft.ACE.OleDb.12.0;Data source=" +@"D:\web\App_Data\db1.accdb";
OleDbConnection oleConnection = new OleDbConnection(ConnStr);
oleConnection.Open();
OleDbCommand mycommand = new OleDbCommand("select * from tUser where uname='" + UserName.Text+"' and upwd='" + Password.Text + "'", oleConnection);
int count = Convert.ToInt32(mycommand.ExecuteScalar());
if (count > 0)
{
        Session["UserLoginID"] = Login1.UserName;

         Response.Redirect("Default.aspx");
}

oleConnection.Close();

原创粉丝点击