oracle数据库登录和

首先引用百度云两个DLL文件 dbhelpher.DLL 和  Oracle.ManagedDataAccess.dll,加入配置文件sysdb文件

配置文件内容

[DBMODE]
MODE=0
[Oracle]
HOST=192.168.1.147
SERVICE_NAME=TPHY
uid=tphy_qey
pwd=tphy
[Assembly]
mutex=1
[Windows]
softwareN=AutoTrans
softwareP=E:军工智能审核数据采集\VERSION1\AutoTrans\AutoTrans\bin\Debug\\AutoTrans.exe(路径)
[YbjkInterface]
AKB020=AKB020
OPERID=0000
OPERNAME=管理员
GRANTID=
time=1

[TMER]
T=08:00

private void btnLogin_Click(object sender, EventArgs e)
{

//获取登录名
string Name = txtName.Text;


//获取加密后的登录密码

byte[] result = Encoding.Default.GetBytes(this.txtPwd.Text.Trim()); //将字符串转换成字节
MD5 md5 = new MD5CryptoServiceProvider();
byte[] output = md5.ComputeHash(result);//MD5加密
string pwd1 = BitConverter.ToString(output).Replace("-", ""); //获取加密后的字符串 (字母为大写)
string pwd = pwd1.ToLower();//将字符串转换成小写



if (Name.Equals("") || pwd.Equals(""))
{
MessageBox.Show("用户名或密码不能为空");
}
else
{
dbhelpher.OraDBHelper.GetConstr(AppDomain.CurrentDomain.BaseDirectory + "sysdb.ini");
DataTable temp = dbhelpher.OraDBHelper.GetDataTable("SELECT * FROM code_czydm where czydm='" + Name + "' and JMKL='" + pwd + "'");
//DataTable temp = dbhelpher.OraDBHelper.GetDataTable("SELECT * FROM code_czydm where czydm='" + Name + "' and jmkl='" + password + "'");
if (temp.Rows.Count > 0)//判断集合中的个数
{
MessageBox.Show("登录成功");
}
else
{
MessageBox.Show("登录失败!请核对您的账户和密码");
}
string conn = dbhelpher.OraDBHelper.GetConstr(AppDomain.CurrentDomain.BaseDirectory + "sysdb.ini");
try
{
if (!dbhelpher.OraDBHelper.OracleConned(conn))
{
MessageBox.Show("数据库连接失败,请配置!!");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "提示:数据库连接异常请检查配置");
return;
}

}

原文地址:https://www.cnblogs.com/yuanshuo/p/9814732.html