NetQuickJamesFrame/DBHelp/MySql.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using MySql.Data.MySqlClient;
using System.Data;

namespace NetQuickJamesFrame.DBHelp
{
    public class MySql
    {
        private string connectionString = "server={server};database={dbName};username={username};password={password};";

        private string server;
        private string userId;
        private string pwd;
        private string dbName;

        public MySql(string server, string userId, string pwd, string dbName)
        {
            this.server = server;
            this.userId = userId;
            this.pwd = pwd;
            this.dbName = dbName;

            connectionString = "server=" + server + ";database=" + dbName + ";username=" + userId + ";password=" + pwd;
        }

        public int executeNonQuery(string sqlsentence)
        {
            int result = -1;
            using (MySqlConnection conn = new MySqlConnection(connectionString))
            {
                try
                {
                    conn.Open();
                    string sql = sqlsentence;
                    MySqlCommand cmd = new MySqlCommand(sql, conn);
                    result = cmd.ExecuteNonQuery();
                    conn.Close();
                }
                catch (Exception ex)
                {
                    conn.Close();
                    throw new Exception(ex.Message);
                }
            }
            return result;
        }

        public List<string> executeReader(string sqlsentence)
        {
            List<string> result = new List<string>();
            using (MySqlConnection conn = new MySqlConnection(connectionString))
            {
                string sql = sqlsentence;
                MySqlCommand cmd = new MySqlCommand(sql, conn);
                try
                {
后面还有 23 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。