C# 数据库连接笔记
时间:2011-05-10 来源:许明吉博客
// 连接
private OleDbConnection oleConnection1 = null;
public static string connection
{
get
{return"Data Source=dormMIS.mdb;Jet OLEDB:Engine Type=5;Provider=Microsoft.Jet.OLEDB.4.0;";}
}
this.oleConnection1=new OleDbConnection(DormMIS.database.dbConnection.connection); // 指定数据库连接信息
OleDbCommand cmd=new OleDbCommand("",oleConnection1);//定义查询数据类
string sql="select * from userinfo where UName='"+name.Text.Trim()+"' and PWD='"+password.Text.Trim()+"'"; //查询语句
cmd.CommandText=sql;
if (null!=cmd.ExecuteScalar()) //判断查询结果是否为空
{
....
}
相关阅读 更多 +