Database operation base class
Chat demo: http://www.liaofuwu.com
Environment
Supported Operating Systems: Mono for Windows and Linux
Supported databases: Mysql, Oracle, and SQL Server
Default Configuration File Location
The configuration file is dbinit. ini, which must be placed in the root directory of the site. For example:
If the Windows site is located at d: \ www \ wwwroot \, The dbinit. ini file must be placed at d: \ dbinit. ini.
Linux on/dbinit. ini
Set the configuration file path
DBMonoUtility. IniFile. FilePath = "d: \ www \ wwwroot \\";
Configuration File description
######################################## ###
# Key Value
# NAME indicates the configuration connection NAME.
# DBTYPE for expansion (Oracle, MySql, SqlServer)
# DBCONNECTIONSTRING the encrypted database connection string
# INITVECTOR used to decrypt the key of the connection string
######################################## ###
NAME | dbname
DBTYPE | MySql
DBCONNECTIONSTRING | G/Glu ++ 3AoMf9YQ3MxGNsHBy5S3kVHEwL4wTH + expires/IWwAGCYg2gLZk5LmbtZHE =
INITVECTOR | QLyb74sRmMw =
Function Description and call example
DataBasePool. AddDataBaseConnectionString ("database connection pool name", "16-bit Public Key ");
DataBaseOperator. Init ("Database Name ");
SQL statement execution instructions
Public int ExecuteStatement (string expr, List Param );
The expr parameter is an SQL statement.
The param parameter is a parameter list object.
The returned value is the number of affected rows.
Example
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 = "operation successful! ";
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;
Description of stored procedure execution
Public ArrayListExecProcedure (string procName, List Param );
Public DataTableExecProcedure (string procName, List Param, out ArrayListoutAl );
Example
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 = "operation successful! ";
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;
Link address of the connection string encryption and decryption Tool
Encryption and decryption please visit: http://tools.liaofuwu.com/dbinit.aspx
Encryption
Decryption
Download