Beispiel #1
0
        public override DataSet GetDataSet(string sql, DbParam[] dp, int startRecord, int maxRecords)
        {
            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;
                    }
                }
            }
            OdbcDataAdapter da = new OdbcDataAdapter(od);
            DataSet         ds = new DataSet();

            da.Fill(ds, startRecord, maxRecords, "Table0");
            return(ds);
        }
Beispiel #2
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);
        }