您的位置:首页 > 数据库

ASP.NET连接Access数据库代码

2012-03-28 16:17 423 查看
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();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: