Example #1
0
        public static DataTable GetDataTable(string sql, List <MOdbcParameter> pars)
        {
            OdbcParameter[] parameters = null;
            if (pars != null)
            {
                parameters = new OdbcParameter[pars.Count];
                for (var i = 0; i < pars.Count; i++)
                {
                    var par = pars[i];
                    parameters[i] = new OdbcParameter(par.Name,
                                                      (OdbcType)Enum.Parse(typeof(OdbcType), par.OType.ToString()))
                    {
                        Value = par.Value
                    };
                }
            }
            var connectionString = GetCompanySqlConnect();
            var dataSet          = OdbcHelper.ExecuteDataset(connectionString, CommandType.Text, sql, parameters);
            var data             = dataSet.Tables[0];

            return(data);
        }