赞
踩
数据库操作基类
聊天demo:http://www.liaofuwu.com
支持操作系统:Windows、Linux的Mono
支持数据库:Mysql、Oracle、Sql Server
配置文件为dbinit.ini,文件需放置于站点根目录。如:
Windows站点位于d:\www\wwwroot\,则dbinit.ini文件需放置于d:\dbinit.ini
Linux放置于/dbinit.ini
DBMonoUtility.IniFile.FilePath ="d:\\www\\wwwroot\\";
###########################################
# Key Value
# NAME 是配置连接名
# DBTYPE 用于扩展(Oracle,MySql,SqlServer)
# DBCONNECTIONSTRING 加密后的数据库连接字符串
# INITVECTOR 用于解密连接字符串的密钥
###########################################
NAME | dbname
DBTYPE | MySql
DBCONNECTIONSTRING | G/Glu++3AoMf9YQ3MxGNsHBy5S3kVHEwL4wTH+ffEZJWWjZtr7ta529B4nuVDXk96CG0oKORXXsauh52mIaAxZH4WUb02lVnSR2rXUMfj7ulSG6cUGscO/IWwAGCYg2gLZk5LmbtZHE=
INITVECTOR | QLyb74sRmMw=
public int ExecuteStatement (string expr,List<ParamItem> param);
参数expr为Sql语句
参数param为参数列表对象
返回值为受影响行数
DataBaseOperator dbo = null;
result = new InvokeResult();
try
{
dbo = new DataBaseOperator();
string sqlStr = @"update XXUserPropsChangeLog set `status` =@iStatus,`desc`=@sDesc where logId = @iLogId and userId = @iUserId";
ParamCollections pc = new ParamCollections();
pc.Add("@iStatus", "1", DataType.INT);
pc.Add("@sDesc", "XXXX", DataType.STRING);
pc.Add("@iLogId",recordId.ToString(),DataType.INT);
pc.Add("@iUserId",userId.ToString(),DataType.INT);
result.ReturnObject = dbo.ExecuteStatement(sqlStr, pc.GetParams(true));
result.Message = "操作成功! ";
result.Result = true;
}
catch (Exception ex)
{
result.Result = false;
result.Message = ex.Message;
result.ErrorObject = this;
}
finally
{
if (null!= dbo)
{
dbo.Close();
dbo = null;
}
}
return result;
public ArrayListExecProcedure(string procName, List<ParamItem>param);
public DataTableExecProcedure(string procName, List<ParamItem>param, out ArrayListoutAl);
DataBaseOperator dbo = null;
result = new InvokeResult();
try
{
dbo = new DataBaseOperator();
string sqlStr = @"P_User_Handshake";
ParamCollections pc = new ParamCollections();
pc.Add("@iRoomId",roomId.ToString(),DataType.INT,InOutFlag.IN);
pc.Add("@iUserId",userId.ToString(),DataType.INT,InOutFlag.IN);
pc.Add("@iInterval",interval.ToString(),DataType.INT,InOutFlag.IN);
result.ReturnObject = dbo.ExecProcedure(sqlStr, pc.GetParams());
result.Message = "操作成功! ";
result.Result = true;
}
catch (Exception ex)
{
result.Result = false;
result.Message = ex.Message;
result.ErrorObject = this;
}
finally
{
if (null!= dbo)
{
dbo.Close();
dbo = null;
}
}
return result;
加解密请访问:http://tools.liaofuwu.com:8080/dbinit.aspx
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。