ddtek.oracle.dll使用相关
内容来自互联网
ddtek.oracle.dll 可以不安装Oracle客户端,直接使用其来登录Oracle服务器,
数据库连接(后面一种为双机集群):
var conn = new DDTek.Oracle.OracleConnection(); conn.ConnectionString = "Host=172.16.1.32;Port=1521;User ID=slmesuser;Password=slmesuser;Service Name=tqmes"; conn.Open();
string conStr = "Host=10.0.1.1;Port=1521;User ID=scott;Password=tiger; Service Name=ORCL;Alternate Servers=(Host=10.0.1.2;Port=1521;Service Name=ORCL)";
使用上,与OracleClient基本相同,但在OracleCommand的Parameter定义和使用上略有不同,如下:
OracleClient:
- OracleCommand mCmd = new OracleCommand("insert into " + sTable + "(test1,test2) values('111',:mBlob)", mCon);
- mCmd.Parameters.Add("mBlob", OracleType.Blob, blob.Length).Value = blob;
- return mCmd.ExecuteNonQuery();
ddtek
- OracleCommand mCmd = new OracleCommand("insert into " + sTable + "(test1,test2) values('111',?)", mCon);
- mCmd.BindByName = true;
- mCmd.Parameters.Add(":mBlob", OracleDbType.Blob, blob.Length).Value = blob;
- return mCmd.ExecuteNonQuery();
DDTEK里,SQL语句中使用?代替变量,下边按照Parameters数组中的顺序依次赋值