当前位置: 首页>>代码示例>>C#>>正文


C# DbType.Contains方法代码示例

本文整理汇总了C#中DbType.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# DbType.Contains方法的具体用法?C# DbType.Contains怎么用?C# DbType.Contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DbType的用法示例。


在下文中一共展示了DbType.Contains方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExecuteSelect

        internal static DataSet ExecuteSelect(EDtxReaderType connType, int timeout, IDbConnection conn, string cmdText, ParamHelper[] paramList, ref TimeSpan executionTime)
        {
            DateTime started = DateTime.Now;
            IDataReader reader = null;
            IDbCommand cmd = null;
            bool bConnOpenedHere = EnsureConnectionOpen(conn);
            IDbTransaction transaction = conn.BeginTransaction();
            DataSet retv = new DataSet();
            try
            {
                cmd = conn.CreateCommand();
                cmd.CommandTimeout = timeout;
                cmd.Transaction = transaction;
                cmd.CommandText = cmdText;
                DbType[] reqLenTypes = new DbType[] { DbType.AnsiString, DbType.AnsiStringFixedLength, DbType.String, DbType.StringFixedLength, DbType.Binary, DbType.Object, DbType.Xml };
                for (int i = 0; i < paramList.Length; i++)
                {
                    IDbDataParameter idb = cmd.CreateParameter();
                    cmd.Parameters.Add(HelperFunctions.BuildParameter(idb, paramList[i]));
                    if(reqLenTypes.Contains(idb.DbType))
                    {
                        if (idb is OdbcParameter)
                        {
                            (idb as OdbcParameter).Size = paramList[i].Size;
                        }
                        else if (idb is CtreeSqlParameter)
                        {
                            (idb as CtreeSqlParameter).Size = paramList[i].Size;
                        }
                    }
                }
                switch(connType)
                {
                    case EDtxReaderType.Adapter:
                    case EDtxReaderType.FaircomAdapter:
                        {
                            IDbDataAdapter adap = GetAdapter(connType, cmd);
                            retv.BeginInit();

                            //Since the FillSchema and Fill functions return the same instance of 'DataTable'
                            //There is probably a better way of doing this, but for sake of explination
                            //Read the db schema
                            bool bSchemaFound = false;
                            DataTable[] dta = adap.FillSchema(retv, SchemaType.Source);
                            DataTable clone = null;
                            if(dta.Length > 0)
                            {
                                bSchemaFound = true;
                                dta[0].TableName = "SchemaTable"; //Ensure the table is named 'SchemaTable'
                                retv.Tables.Remove(dta[0]); //Drop the table from the dataset
                                clone = dta[0].Clone(); //Clone the results
                                dta[0].TableName = "Table"; //Rename the datatable instance back to table
                            }
                            adap.Fill(retv); //Fill 'Table' with the actual results
                            if(bSchemaFound && clone != null)
                                retv.Tables.Add(clone); //Now add the 'schematable' back to the results

                            retv.EndInit();
                            break;
                        }
                    default:
                        {
                            DataTable dt;
                            reader = cmd.ExecuteReader();
                            if (reader.FieldCount > 0)
                            {
                                retv.Tables.Add(dt = new DataTable("Table"));
                                retv.Tables.Add(reader.GetSchemaTable());
                                switch (connType)
                                {
                                    case EDtxReaderType.FaircomReader:
                                    case EDtxReaderType.Reader:
                                        {
                                            dt.Load(reader, LoadOption.OverwriteChanges);
                                        }
                                        break;
                                    case EDtxReaderType.FaircomReaderSafe:
                                    case EDtxReaderType.ReaderSafe:
                                    default:
                                        {

                                            bool columnsBuilt = false;
                                            while (reader.Read())
                                            {
                                                if (columnsBuilt == false)
                                                {
                                                    BuildColumnData(dt, reader);
                                                    columnsBuilt = true;
                                                }
                                                AddDataRow(dt, reader);
                                            }
                                        }
                                        break;

                                }
                            }
                            break;
                        }
                }
                transaction.Commit();
//.........这里部分代码省略.........
开发者ID:cgabilla,项目名称:cKarp,代码行数:101,代码来源:QueryHelper.cs


注:本文中的DbType.Contains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。