Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        public override DataSet GetDataSet(string sql, DbParam[] dp, int startRecord, int maxRecords)
        {
            OleDbCommand od = new OleDbCommand(sql, oc);

            od.Transaction = ot;

            if (dp != null)
            {
                for (int i = 0; i < dp.Length; i++)
                {
                    if (dp[i] != null)
                    {
                        od.Parameters.Add(dp[i].Name, DbParam.GetOleDbType(dp[i].Type), dp[i].Size).Value = dp[i].Value;
                    }
                }
            }

            OleDbDataAdapter da = new OleDbDataAdapter(od);
            DataSet          ds = new DataSet();

            da.Fill(ds, startRecord, maxRecords, "Table0");
            return(ds);
        }
Exemplo n.º 3
0
        public override object GetValue(string sql, DbParam[] dp)
        {
            //OdbcCommand od = new OdbcCommand(ReplaceParam(sql,dp),sc);
            OdbcCommand od = new OdbcCommand(sql, sc);

            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.GetOdbcType(dp[i].Type), dp[i].Size).Value = dp[i].Value;
                    }
                }
            }

            object rst = null;

            if (od.Connection.State == ConnectionState.Open)
            {
                rst = od.ExecuteScalar();
            }
            else
            {
                od.Connection.Open();
                try
                {
                    rst = od.ExecuteScalar();
                }
                finally
                {
                    od.Connection.Close();
                }
            }
            return(rst);
        }
Exemplo n.º 4
0
        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);
        }