示例#1
0
    public static int ExeSqlCommand(string sqlCommand)
    {
        int           num;
        SqlConnection sqlConnection = new SqlConnection(DBA.strConnection);
        SqlCommand    sqlCommand1   = new SqlCommand(sqlCommand, sqlConnection);
        int           num1          = -1;

        try
        {
            sqlConnection.Open();
        }
        catch
        {
            num = -1;
            return(num);
        }
        try
        {
            num1 = sqlCommand1.ExecuteNonQuery();
        }
        catch (Exception exception1)
        {
            Exception exception = exception1;
            WebFun.ScriptMessage(string.Concat("SQL错误:", exception.Message), true);
        }
        sqlConnection.Close();
        num = num1;
        return(num);
    }
示例#2
0
    public static DataSet GetList(string TBName, int PageSize, int CurPage, string KeyField, string Condition, string Order)
    {
        DataSet       dataSet       = null;
        SqlConnection sqlConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnString"]);

        try
        {
            SqlParameter[] sqlParameterArray = new SqlParameter[] { SqlDBA.MakeInParam("@TBName", SqlDbType.NVarChar, 100, TBName), SqlDBA.MakeInParam("@PageSize", SqlDbType.Int, 10, PageSize), SqlDBA.MakeInParam("@CurPage", SqlDbType.Int, 10, CurPage), SqlDBA.MakeInParam("@KeyField", SqlDbType.NVarChar, 100, KeyField), SqlDBA.MakeInParam("@Condition", SqlDbType.NVarChar, 200, Condition), SqlDBA.MakeInParam("@Order", SqlDbType.NVarChar, 200, Order) };
            SqlDBA.RunProc(sqlConnection, "XW_PublicTurnPageWebSite", sqlParameterArray, out dataSet);
        }
        catch (Exception exception1)
        {
            Exception exception = exception1;
            WebFun.ScriptMessage(string.Concat("SqlDBA发生错误,信息为:", exception.Message), true);
        }
        return(dataSet);
    }
示例#3
0
    public static DataSet GetNewList(string 表名, int 每页显示数, int 当前页, string 查询条件, string 表的主键, string 排序字段, int 排序方法, out int 总页数, out int 记录数)
    {
        DataSet       dataSet       = null;
        SqlConnection sqlConnection = new SqlConnection(DBA.strConnection);

        总页数 = 0;
        记录数 = 0;
        try
        {
            SqlParameter[] sqlParameterArray  = new SqlParameter[] { SqlDBA.MakeInParam("@tblName", SqlDbType.NVarChar, 200, 表名), SqlDBA.MakeInParam("@pageSize", SqlDbType.Int, 10, 每页显示数), SqlDBA.MakeInParam("@page", SqlDbType.Int, 10, 当前页), SqlDBA.MakeInParam("@strCondition", SqlDbType.NVarChar, 1000, 查询条件), SqlDBA.MakeInParam("@ID", SqlDbType.NVarChar, 150, 表的主键), SqlDBA.MakeInParam("@fldSort", SqlDbType.NVarChar, 200, 排序字段), SqlDBA.MakeInParam("@Sort", SqlDbType.Bit, 10, 排序方法), SqlDBA.MakeOutParam("@pageCount", SqlDbType.Int, 4), SqlDBA.MakeOutParam("@Counts", SqlDbType.Int, 4) };
            SqlParameter[] sqlParameterArray1 = sqlParameterArray;
            SqlDBA.RunProc(sqlConnection, "proc_ListPageInt", sqlParameterArray1, out dataSet);
            总页数 = Convert.ToInt32(sqlParameterArray1[7].Value);
            记录数 = Convert.ToInt32(sqlParameterArray1[8].Value);
        }
        catch (Exception exception1)
        {
            Exception exception = exception1;
            WebFun.ScriptMessage(string.Concat("SqlDBA发生错误,信息为:", exception.Message), true);
        }
        return(dataSet);
    }
示例#4
0
    public static DataTable GetDBToDataTable(string sqlCommand)
    {
        DataTable      dataTable;
        SqlConnection  sqlConnection  = new SqlConnection(DBA.strConnection);
        SqlDataAdapter sqlDataAdapter = new SqlDataAdapter()
        {
            SelectCommand = new SqlCommand(sqlCommand, sqlConnection)
        };
        SqlDataAdapter sqlDataAdapter1 = sqlDataAdapter;

        try
        {
            sqlConnection.Open();
        }
        catch
        {
            dataTable = null;
            return(dataTable);
        }
        DataTable dataTable1 = new DataTable();

        try
        {
            sqlDataAdapter1.Fill(dataTable1);
        }
        catch (Exception exception1)
        {
            Exception exception = exception1;
            WebFun.ScriptMessage(string.Concat("SQL错误:", exception.Message), true);
        }
        sqlDataAdapter1.Dispose();
        sqlConnection.Close();
        sqlConnection.Dispose();
        dataTable = dataTable1;
        return(dataTable);
    }