public override DataSet GetDataSet(string sql, DbParam[] dp, int startRecord, int maxRecords) { SqlCommand od = new SqlCommand(ReplaceParam(sql, dp), sc); od.CommandTimeout = 300; od.Transaction = st; if (dp != null) { for (int i = 0; i < dp.Length; i++) { if (dp[i] != null) { od.Parameters.Add(dp[i].Name, DbParam.GetSqlType(dp[i].Type), dp[i].Size).Value = dp[i].Value; } } } SqlDataAdapter da = new SqlDataAdapter(od); DataSet ds = new DataSet(); da.Fill(ds, startRecord, maxRecords, "Table0"); return(ds); }
public override int DoCommand(string sql, DbParam[] dp) { SqlCommand od = new SqlCommand(ReplaceParam(sql, dp), sc); od.CommandTimeout = 300; od.Transaction = st; if (dp != null) { for (int i = 0; i < dp.Length; i++) { if (dp[i] != null) { od.Parameters.Add(dp[i].Name, DbParam.GetSqlType(dp[i].Type), dp[i].Size).Value = dp[i].Value; } } } int rst = -1; if (od.Connection.State == ConnectionState.Open) { rst = od.ExecuteNonQuery(); } else { od.Connection.Open(); try { rst = od.ExecuteNonQuery(); } finally { od.Connection.Close(); } } return(rst); }