Database Operations for online live video broadcast systems based on C # Step-by-Step chat systems-Mono environments for Windows and Linux

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.