DBUtility/SqlServer.cs

(完整代码) 1KB

using System.Data;
using System.Data.Common;
using System.Data.SqlClient;

namespace DBUtility
{
    public class SqlServer : DbHelper
    {
        public override IDbConnection CreateConnection()
        {
            return new SqlConnection(ConnectionString);
        }

        public override IDbCommand CreateCommand()
        {
            return new SqlCommand();
        }

        public override DbDataAdapter CreateDataAdapter(IDbCommand selectCommand,
            IDbCommand insertCommand, IDbCommand deleteCommand, IDbCommand updateCommand)
        {
            SqlDataAdapter adapter = new SqlDataAdapter();
            if (selectCommand != null)
                adapter.SelectCommand = selectCommand as SqlCommand;
            if (insertCommand != null)
                adapter.InsertCommand = insertCommand as SqlCommand;
            if (deleteCommand != null)
                adapter.DeleteCommand = deleteCommand as SqlCommand;
            if (updateCommand != null)
                adapter.UpdateCommand = updateCommand as SqlCommand;
            return adapter;
        }

        public override IDbDataParameter CreateDbParameter(string parameterName)
        {
            IDbDataParameter parameter = new SqlParameter();
            parameter.ParameterName = parameterName.Replace("?", "@").Replace(":", "@");
            return parameter;
        }
    }
}

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

AI 解读 AI

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

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