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


C# OdbcDataAdapter.Dispose方法代码示例

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


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

示例1: GetDataTable

        public static string GetDataTable(ref DataTable _ConnectionDt, ref DataTable ReturnDt, string SelectCommand)
        {
            OdbcConnection odbc_Conn = new OdbcConnection();
            OdbcDataAdapter odbcAdap = new OdbcDataAdapter();
            OdbcCommand odbcCmd = new OdbcCommand();

            string ErrMsg = string.Empty;

            try
            {
                ErrMsg = MakeInformixConnection(ref _ConnectionDt, ref odbc_Conn);

                if (ErrMsg == string.Empty)
                {
                        odbcCmd.Connection = odbc_Conn;
                        odbcCmd.CommandText = SelectCommand;
                        odbcAdap.SelectCommand = odbcCmd;
                        odbcAdap.Fill(ReturnDt);
                        odbc_Conn.Close();
                }
                return ErrMsg;
            }
            catch (Exception err)
            {
                return err.Message;
            }
            finally
            { odbcAdap.Dispose(); odbcCmd.Dispose(); odbc_Conn.Dispose(); }
        }
开发者ID:safaintegrated,项目名称:asm,代码行数:29,代码来源:Informix.cs

示例2: GetData

        public static DataTable GetData(string strConn, string strSql, int timeout)
        {
            DataTable dt = new DataTable("td");

            using (OdbcConnection conn = new OdbcConnection(strConn))
            {
                conn.Open();

                OdbcCommand cmd = null;
                OdbcDataAdapter da = null;

                try
                {
                    cmd = new OdbcCommand(strSql, conn) { CommandTimeout = timeout };
                    da = new OdbcDataAdapter { SelectCommand = cmd };

                    da.Fill(dt);

                    return dt;
                }
                catch (Exception ex)
                {
                    throw new Exception("error getting data " + ex.Message);
                }
                finally
                {
                    if (da != null) { da.Dispose(); }
                    if (cmd != null) { cmd.Dispose(); }

                    conn.Close();
                }
            }
        }
开发者ID:nelsonjma,项目名称:DbConnection,代码行数:33,代码来源:odbc_conn.cs

示例3: FetchTable

        public static string FetchTable(string SelectCommand, string XMLconnectionPhysicalFilePath, ref DataTable Dt)
        {
            OdbcConnection OdbcConn = new OdbcConnection();
            OdbcCommand OdbcCmd = new OdbcCommand();
            OdbcDataAdapter OdbcAdap = new OdbcDataAdapter();

            try
            {
                string DbErr = InitializeODBCConnection(ref OdbcConn, XMLconnectionPhysicalFilePath);

                if (DbErr == string.Empty)
                {
                    OdbcCmd.Connection = OdbcConn;
                    OdbcCmd.CommandText = SelectCommand;
                    OdbcAdap.SelectCommand = OdbcCmd;
                    OdbcAdap.Fill(Dt);
                    return string.Empty;
                }
                else
                    return DbErr;
            }
            catch (Exception err)
            {
                return err.Message;
            }
            finally
            { OdbcAdap.Dispose(); OdbcCmd.Dispose(); OdbcConn.Close(); OdbcConn.Dispose(); }
        }
开发者ID:safaintegrated,项目名称:asm,代码行数:28,代码来源:Informix.cs

示例4: GetRealData

        public DataSet GetRealData()
        {
            //string RealConnectionSting = "DSN=FIX Dynamics Real Time Data";//实时数据库连接字符串
            ////string HisConnectionSting = "DSN=FIX Dynamics Historical Data";//历史数据库连接字符串
            //OdbcConnection RealConnection;//实时数据库连接
            ////OdbcConnection HisConnection;//历史数据库连接
            //DataSet errds = new DataSet();

            try
            {
                //RealConnection = new OdbcConnection(RealConnectionSting);
                //RealConnection.Open();

                OdbcDataAdapter adapter = new OdbcDataAdapter("select A_CV from FIX", RealConnection);
                DataSet ds = new DataSet();
                adapter.Fill(ds, "FIX");
                adapter.Dispose();
                return ds;
                
               // RealConnection..Close();
            }
            catch (Exception ex)
            {
                return new DataSet();
                

            }

        }
开发者ID:neroanelli,项目名称:DCS.Web,代码行数:29,代码来源:IFixData.cs

示例5: LoadExcel

        public System.Data.DataTable LoadExcel(string pPath)
        {
            string connString = "Driver={Driver do Microsoft Excel(*.xls)};DriverId=790;SafeTransactions=0;ReadOnly=1;MaxScanRows=16;Threads=3;MaxBufferSize=2024;UserCommitSync=Yes;FIL=excel 8.0;PageTimeout=5;";  //连接字符串

            //简单解释下这个连续字符串,Driver={Driver do Microsoft Excel(*.xls)} 这种连接写法不需要创建一个数据源DSN,DRIVERID表示驱动ID,Excel2003后都使用790,

            //FIL表示Excel文件类型,Excel2007用excel 8.0,MaxBufferSize表示缓存大小, 如果你的文件是2010版本的,也许会报错,所以要找到合适版本的参数设置。

            connString += "DBQ=" + pPath; //DBQ表示读取Excel的文件名(全路径)
            OdbcConnection conn = new OdbcConnection(connString);
            OdbcCommand cmd = new OdbcCommand();
            cmd.Connection = conn;
            //获取Excel中第一个Sheet名称,作为查询时的表名
            string sheetName = this.GetExcelSheetName(pPath);
            string sql = "select * from [" + sheetName.Replace('.', '#') + "$]";
            cmd.CommandText = sql;
            OdbcDataAdapter da = new OdbcDataAdapter(cmd);
            DataSet ds = new DataSet();
            try
            {
                da.Fill(ds);
                return ds.Tables[0];    //返回Excel数据中的内容,保存在DataTable中
            }
            catch (Exception x)
            {
                ds = null;
                throw new Exception("从Excel文件中获取数据时发生错误!可能是Excel版本问题,可以考虑降低版本或者修改连接字符串值");
            }
            finally
            {
                cmd.Dispose();
                cmd = null;
                da.Dispose();
                da = null;
                if (conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
                conn = null;
            }
        }
开发者ID:shentianyi,项目名称:MoldSmartDevice,代码行数:41,代码来源:ImExcel.cs

示例6: GetData

        private DataTable GetData(string Query)
        {
            string _connStr = Settings.Database.Conn.
                Replace("{Database}", Settings.Database.Name).
                Replace("{Server}", Settings.Database.Host).
                Replace("{Port}", Settings.Database.Port).
                Replace("{Username}", Settings.Database.User).
                Replace("{Password}", Settings.Database.Pass);

            DataTable _dt = new DataTable();

            DBError = "";

            using (OdbcConnection _dbconn = new OdbcConnection(_connStr))
            {
                try
                {
                    _dbconn.Open();

                    using (OdbcCommand _command = new OdbcCommand())
                    {
                        _command.Connection = _dbconn;
                        _command.CommandType = CommandType.Text;
                        _command.CommandText = Query;

                        OdbcDataAdapter _adap = new OdbcDataAdapter(_command);

                        _adap.Fill(_dt);
                        _adap.Dispose();
                    }
                }
                catch (Exception _ex)
                {
                    DBError = _ex.Message;

                    if (DBError.Substring(0,(DBError.Length >> 1) - 1).Equals(DBError.Substring((DBError.Length >> 1) + 1)))
                    {
                        // ODBC is doubling up error messages for some reason.

                        DBError = DBError.Substring(0, (DBError.Length >> 1) - 1);
                    }

                    _dt.Columns.Add("Empty", typeof(string));
                }

                if (_dt.Rows.Count < 1)
                {
                    _dt.Rows.Add();
                }
            }

            return _dt;
        }
开发者ID:Shendare,项目名称:EQEmuItemEditor,代码行数:53,代码来源:formMain.cs

示例7: select

        /// <summary>
        /// ��Ʈw�d�M��k
        /// </summary>
        /// <param name="selectcmd"></param>
        /// <returns></returns>
        public System.Data.DataTable select(ICommand selectcmd)
        {
            string selectCmd = selectcmd.getCommand();
            try
            {
                cmd = new OdbcCommand(selectCmd, GetConn());
                OdbcDataAdapter da = new OdbcDataAdapter(cmd);

                //cmd = new IBM.Data.DB2.DB2Command(selectCmd, GetConn());
                //IBM.Data.DB2.DB2DataAdapter da = new IBM.Data.DB2.DB2DataAdapter(cmd);
                System.Data.DataTable DT = new System.Data.DataTable();
                da.Fill(DT);
                da.Dispose();
                return DT;
            }
            catch
            {
                try
                {
                    lock (typeof(OdbcConnection))
                    {
                        GetConn().Close();
                        GetConn().Open();
                        cmd = new OdbcCommand(selectCmd, GetConn());

                        OdbcDataAdapter da = new OdbcDataAdapter(cmd);
                        //cmd = new IBM.Data.DB2.DB2Command(selectCmd, GetConn());
                        //IBM.Data.DB2.DB2DataAdapter da = new IBM.Data.DB2.DB2DataAdapter(cmd);
                        System.Data.DataTable DT = new System.Data.DataTable();
                        da.Fill(DT);
                        da.Dispose();

                        return DT;
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
开发者ID:ufjl0683,项目名称:Center,代码行数:46,代码来源:A_OdbcConnect.cs

示例8: Bind

    /// <summary>
    /// Execute คำสั่ง SQL แล้วเก็บค่าที่ได้ใส่ DataTable
    /// </summary>
    /// <param name="strSql">SQL Query</param>
    /// <param name="strDBType">ชนิดของฐานข้อมูล เช่น sql,odbc,mysql</param>
    /// <param name="appsetting_name">ชื่อตัวแปรที่เก็บ ConnectionString ในไฟล์ AppSetting</param>
    /// <returns>ข้อมูล</returns>
    /// <example>
    /// clsSQL.Bind("SELECT * FROM member",clsSQL.DBType.MySQL,"cs");
    /// </example>
    public DataTable Bind(string strSql, DBType dbType, string appsetting_name)
    {
        #region Variable
        var csSQL = System.Configuration.ConfigurationManager.AppSettings[appsetting_name];
        var dt = new DataTable();
        #endregion
        #region Procedure
        if (!string.IsNullOrEmpty(csSQL))
        {
            if (dbType == DBType.SQLServer)
            {
                #region SQLServer
                var myConn_SQL = new SqlConnection(csSQL);
                var myDa_SQL = new SqlDataAdapter(strSql, myConn_SQL);

                myDa_SQL.Fill(dt);
                myConn_SQL.Dispose();
                myDa_SQL.Dispose();
                if (dt.Rows.Count > 0 && dt != null)
                {
                    return dt;
                }
                else
                {
                    dt.Dispose();
                    return null;
                }
                #endregion
            }
            else if (dbType == DBType.ODBC)
            {
                #region ODBC
                var myConn_ODBC = new OdbcConnection(csSQL);
                var myDa_ODBC = new OdbcDataAdapter(strSql, myConn_ODBC);

                myDa_ODBC.Fill(dt);
                myConn_ODBC.Dispose();
                myDa_ODBC.Dispose();
                if (dt.Rows.Count > 0 && dt != null)
                {
                    return dt;
                }
                else
                {
                    dt.Dispose();
                    return null;
                }
                #endregion
            }
            else
            {
                return null;
            }
        }
        else
        {
            return null;
        }
        #endregion
    }
开发者ID:oofdui,项目名称:ContactCheckup-MassConvert,代码行数:70,代码来源:clsSQLNative.cs

示例9: Bind

 public DataTable Bind(string strSQL, string[,] arrParameter, out string outMessage)
 {
     #region Variable
     var csSQL = getConnectionString(cs);
     var dt = new DataTable();
     var i = 0;
     outMessage = "";
     #endregion
     #region Procedure
     if (!string.IsNullOrEmpty(csSQL))
     {
         if (dbType == DBType.SQLServer)
         {
             #region SQLServer
             try
             {
                 using (var myConn_SQL = new SqlConnection(csSQL))
                 using (var myDa_SQL = new SqlDataAdapter(QueryFilterByDatabaseType(strSQL), myConn_SQL))
                 {
                     for (i = 0; i < arrParameter.Length / arrParameter.Rank; i++)
                     {
                         myDa_SQL.SelectCommand.Parameters.AddWithValue(arrParameter[i, 0], arrParameter[i, 1]);
                     }
                     myDa_SQL.Fill(dt);
                     myConn_SQL.Dispose();
                     myDa_SQL.Dispose();
                     if (dt.Rows.Count > 0 && dt != null)
                     {
                         return dt;
                     }
                     else
                     {
                         dt.Dispose();
                         return null;
                     }
                 }
             }
             catch (Exception ex)
             {
                 outMessage = ex.Message;
                 return null;
             }
             #endregion
         }
         else if (dbType == DBType.ODBC)
         {
             #region ODBC
             try
             {
                 using (var myConn_ODBC = new OdbcConnection(csSQL))
                 using (var myDa_ODBC = new OdbcDataAdapter(QueryFilterByDatabaseType(strSQL), myConn_ODBC))
                 {
                     for (i = 0; i < arrParameter.Length / arrParameter.Rank; i++)
                     {
                         myDa_ODBC.SelectCommand.Parameters.AddWithValue(arrParameter[i, 0], arrParameter[i, 1]);
                     }
                     myDa_ODBC.Fill(dt);
                     myConn_ODBC.Dispose();
                     myDa_ODBC.Dispose();
                     if (dt.Rows.Count > 0 && dt != null)
                     {
                         return dt;
                     }
                     else
                     {
                         dt.Dispose();
                         return null;
                     }
                 }
             }
             catch (Exception ex)
             {
                 outMessage = ex.Message;
                 return null;
             }
             #endregion
         }
         else if (dbType == DBType.MySQL)
         {
             #region MySQL
             try
             {
                 using (var myConn_MySQL = new MySql.Data.MySqlClient.MySqlConnection(csSQL))
                 using (var myDa_MySQL = new MySql.Data.MySqlClient.MySqlDataAdapter(QueryFilterByDatabaseType(strSQL), myConn_MySQL))
                 {
                     for (i = 0; i < arrParameter.Length / arrParameter.Rank; i++)
                     {
                         myDa_MySQL.SelectCommand.Parameters.AddWithValue(arrParameter[i, 0], arrParameter[i, 1]);
                     }
                     myDa_MySQL.Fill(dt);
                     myConn_MySQL.Dispose();
                     myDa_MySQL.Dispose();
                     if (dt.Rows.Count > 0 && dt != null)
                     {
                         return dt;
                     }
                     else
                     {
                         dt.Dispose();
                         return null;
//.........这里部分代码省略.........
开发者ID:oofdui,项目名称:ContactCheckupSync,代码行数:101,代码来源:clsSQL.cs

示例10: importar


//.........这里部分代码省略.........
                    Conn.Open();

                    dtPedidoConsulta.SelectCommand = new SqlCommand("(SELECT DISTINCT pedidos.idPedido FROM pedidos) UNION ALL (SELECT DISTINCT pedidos_hist.idPedido FROM pedidos_hist)", Conn);
                    dtPedidoConsulta.Fill(dsPedidoConsulta, "pedidos");

                    cmdPedidos = new SqlCommand();
                    //cmdPedidos.ExecuteNonQuery();

                    for (int rowCount = 0; rowCount < dsExcel.Tables[0].Rows.Count; rowCount++)
                    {
                        if (dsExcel.Tables[0].Rows[rowCount][0].ToString().Length >= 6)
                        {
                            valoresRow = dsExcel.Tables[0].Rows[rowCount][0].ToString().Split(dsExcel.Tables[0].Rows[rowCount][0].ToString()[6]);
                            pedidoExist = false;

                            foreach (DataRow rowSelect in dsPedidoConsulta.Tables[0].Rows)
                            {
                                if (rowSelect[0].ToString() == valoresRow[3]) //-- Compara Si existe el Pedido
                                {
                                    pedidoExist = true;
                                    break;
                                }
                            }

                            if (!pedidoExist)
                            {
                                strQuery = "INSERT INTO pedidos (";
                                queryValues = "";
                                verifyInsert = true;

                                for (int columnCount = 0; columnCount < ColumnsName.Length; columnCount++)
                                {
                                    if (ColumnsName[columnCount] != "tipo")
                                    {
                                        strQuery += ColumnsName[columnCount] + ",";

                                        if (ColumnsName[columnCount] != "ocabi" && (valoresRow[columnCount] == "" || valoresRow[columnCount] == null))
                                        {
                                            verifyInsert = false;
                                        }

                                        switch (ColumnsTypes[columnCount])
                                        {
                                            case "int":
                                                {
                                                    queryValues += valoresRow[columnCount].Trim() + ",";
                                                    break;
                                                }

                                            default:
                                                {
                                                    queryValues += "'" + valoresRow[columnCount].Trim() + "',";
                                                    break;
                                                }
                                        }
                                    }
                                }

                                if (verifyInsert)
                                {
                                    strQuery = strQuery.Substring(0, strQuery.Length - 1) + ") VALUES (" + queryValues.Substring(0, queryValues.Length - 1) + ")";

                                    //Response.Write(strQuery + "<br><br>");

                                    cmdPedidos = new SqlCommand(strQuery, Conn);
                                    cmdPedidos.ExecuteNonQuery();
                                }
                            }
                        }
                    }

                    daExcel.Dispose();
                    dsExcel.Dispose();
                    dsPedidoConsulta.Dispose();
                    dtPedidoConsulta.Dispose();
                    cmdPedidos.Dispose();
                    conn.Close();
                    conn.Dispose();
                    Conn.Close();
                    Conn.Dispose();
                }
            }
            catch (SqlException sqlEx)
            {
                errorFound = true;
                eventTracerLog.createEntry("Importación de Pedidos: " + sqlEx.Message, true);
            }
            catch (Exception ex)
            {
                errorFound = false;
                eventTracerLog.createEntry("Importación de Pedidos: " + ex.Message, true);
            }
            finally
            {
                if (!errorFound)
                {
                    eventTracerLog.createEntry("Importación de Pedidos", false);
                }
            }
        }
开发者ID:pgallar,项目名称:zeni-proveedores,代码行数:101,代码来源:import_pedidos.cs

示例11: Bind

 /// <summary>
 /// Execute คำสั่ง SQL แล้วเก็บค่าที่ได้ใส่ DataTable
 /// </summary>
 /// <param name="strSql">SQL Query</param>
 /// <param name="strDBType">ชนิดของฐานข้อมูล เช่น sql,odbc,mysql</param>
 /// <param name="appSettingName">ชื่อตัวแปรที่เก็บ ConnectionString ในไฟล์ AppSetting</param>
 /// <param name="outMessage">คืนค่าข้อความ กรณีเกิดข้อผิดพลาด</param>
 /// <returns>DataTable</returns>
 /// <example>
 /// string outMessage;
 /// clsSQL.Bind("SELECT * FROM member",clsSQL.DBType.MySQL,"cs",out outMessage);
 /// </example>
 public DataTable Bind(string strSql, DBType dbType, string appSettingName, out string outMessage)
 {
     #region Variable
     var csSQL = (appSettingName.Contains("=") ? appSettingName : System.Configuration.ConfigurationManager.AppSettings[appSettingName]);
     var dt = new DataTable();
     outMessage = "";
     #endregion
     #region Procedure
     if (!string.IsNullOrEmpty(csSQL))
     {
         if (dbType == DBType.SQLServer)
         {
             #region SQLServer
             try
             {
                 using (var myConn_SQL = new SqlConnection(csSQL))
                 using (var myDa_SQL = new SqlDataAdapter(strSql, myConn_SQL))
                 {
                     myDa_SQL.Fill(dt);
                     myConn_SQL.Dispose();
                     myDa_SQL.Dispose();
                     if (dt.Rows.Count > 0 && dt != null)
                     {
                         return dt;
                     }
                     else
                     {
                         dt.Dispose();
                         return null;
                     }
                 }
             }
             catch (Exception ex)
             {
                 outMessage = ex.Message;
                 return null;
             }
             #endregion
         }
         else if (dbType == DBType.ODBC)
         {
             #region ODBC
             try
             {
                 using (var myConn_ODBC = new OdbcConnection(csSQL))
                 using (var myDa_ODBC = new OdbcDataAdapter(strSql, myConn_ODBC))
                 {
                     myDa_ODBC.Fill(dt);
                     myConn_ODBC.Dispose();
                     myDa_ODBC.Dispose();
                     if (dt.Rows.Count > 0 && dt != null)
                     {
                         return dt;
                     }
                     else
                     {
                         dt.Dispose();
                         return null;
                     }
                 }
             }
             catch (Exception ex)
             {
                 outMessage = ex.Message;
                 return null;
             }
             #endregion
         }
         else
         {
             outMessage = "Not found DBType.";
             return null;
         }
     }
     else
     {
         outMessage = "Not found AppSettingName.";
         return null;
     }
     #endregion
 }
开发者ID:oofdui,项目名称:GooDatabaseViewer,代码行数:93,代码来源:clsSQLNative.cs

示例12: Dispose

		public void Dispose ()
		{
			OdbcDataAdapter da = new OdbcDataAdapter ();
			da.DeleteCommand = new OdbcCommand ();
			da.InsertCommand = new OdbcCommand ();
			da.SelectCommand = new OdbcCommand ();
			da.UpdateCommand = new OdbcCommand ();
			da.Dispose ();

			Assert.IsNull (da.DeleteCommand, "#1");
			Assert.IsNull (da.InsertCommand, "#2");
			Assert.IsNull (da.SelectCommand, "#3");
			Assert.IsNotNull (da.TableMappings, "#4");
			Assert.AreEqual (0, da.TableMappings.Count, "#5");
			Assert.IsNull (da.UpdateCommand, "#6");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:16,代码来源:OdbcDataAdapterTest.cs

示例13: importar


//.........这里部分代码省略.........
                                                    break;
                                                }
                                            case "datetime":
                                                {
                                                    fecha = valoresRow[columnCount].Trim().Split('.');

                                                    if (pedidoExist)
                                                    {
                                                        if (fecha[1] != "00")
                                                        {
                                                            strQuery += "'" + fecha[1] + "-" + fecha[0] + "-" + fecha[2] + "',";
                                                        }
                                                        else
                                                        {
                                                            strQuery += "null,";
                                                        }
                                                    }
                                                    else
                                                    {
                                                        if (fecha[1] != "00")
                                                        {
                                                            queryValues += "'" + fecha[1] + "-" + fecha[0] + "-" + fecha[2] + "',";
                                                        }
                                                        else
                                                        {
                                                            queryValues += "null,";
                                                        }

                                                    }

                                                    break;
                                                }

                                            default:
                                                {
                                                    if (pedidoExist)
                                                    {
                                                        strQuery += "'" + valoresRow[columnCount].Trim() + "',";
                                                    }
                                                    else
                                                    {
                                                        queryValues += "'" + valoresRow[columnCount].Trim() + "',";
                                                    }
                                                    break;
                                                }
                                        }
                                    }
                                }
                                if (verifyInsert)
                                {
                                    if (pedidoExist)
                                    {
                                        strQuery = strQuery.Substring(0, strQuery.Length - 1) + " WHERE idFactura = '" + valoresRow[4] + "' and idProveedor = " + valoresRow[1];
                                    }
                                    else
                                    {
                                        strQuery = strQuery.Substring(0, strQuery.Length - 1) + ") VALUES (" + queryValues.Substring(0, queryValues.Length - 1) + ")";
                                    }

                                    cmdPedidos = new SqlCommand(strQuery, Conn);
                                    cmdPedidos.ExecuteNonQuery();
                                }
                                if (!verifyInsert)
                                {
                                    strQuery = "";
                                }
                                File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + "/log_facturacion.txt", File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "/log_facturacion.txt").ToString() + "\n" + "linea: " + (rowCount + 1) + " " + " Ejecucion: " + verifyInsert + " Datos: " + dsExcel.Tables[0].Rows[rowCount][0].ToString() + " Consulta ejecutada: " + strQuery);
                            }
                        }
                    }

                    daExcel.Dispose();
                    dsExcel.Dispose();
                    dsPedidoConsulta.Dispose();
                    dtPedidoConsulta.Dispose();
                    cmdPedidos.Dispose();
                    conn.Close();
                    conn.Dispose();
                    Conn.Close();
                    Conn.Dispose();
                }
            }
            catch (SqlException sqlEx)
            {
                errorFound = true;
                eventTracerLog.createEntry("Importación de Facturación de sql: " + sqlEx.Message, true);
            }
            catch (Exception ex)
            {
                errorFound = true;
                eventTracerLog.createEntry("Importación de Facturación de parseo: " + ex.Message, true);
            }
            finally
            {
                if (!errorFound)
                {
                    eventTracerLog.createEntry("Importación de Facturación correcta", false);
                }
            }
        }
开发者ID:pgallar,项目名称:zeni-proveedores,代码行数:101,代码来源:import_facturacion.cs

示例14: Bind

    /// <summary>
    /// Execute คำสั่ง SQL แล้วเก็บค่าที่ได้ใส่ DataTable โดยสามารถระบุ SQL Parameter ได้
    /// </summary>
    /// <param name="strSql">SQL Query</param>
    /// <param name="arrParameter">SQL Parameter (new string[,] { { "?ID", txtTest.Text } })</param>
    /// <param name="strDBType">ชนิดของฐานข้อมูล เช่น sql,odbc,mysql</param>
    /// <param name="appsetting_name">ชื่อตัวแปรที่เก็บ ConnectionString ในไฟล์ AppSetting</param>
    /// <returns>ข้อมูล</returns>
    /// <example>
    /// strSQL.Append("SELECT email FROM member WHERE id=?ID");
    /// dt = Bind(strSQL.ToString(), new string[,] { { "?ID", txtTest.Text } }, clsSQL.DBType.MySQL, "cs");
    /// </example>
	public DataTable Bind(string strSql, string[,] arrParameter, DBType dbType, string appsetting_name)
    {
        string csSQL = System.Configuration.ConfigurationManager.AppSettings[appsetting_name];
        DataTable dt = new DataTable();
        int i;

        if (!string.IsNullOrEmpty(csSQL))
        {
            if (dbType == DBType.SQLServer)
            {
                SqlConnection myConn_SQL = new SqlConnection(csSQL);
                SqlDataAdapter myDa_SQL = new SqlDataAdapter(strSql, myConn_SQL);

                for (i = 0; i < arrParameter.Length / arrParameter.Rank; i++)
                {
                    myDa_SQL.SelectCommand.Parameters.AddWithValue(arrParameter[i, 0], arrParameter[i, 1]);
                }
                myDa_SQL.Fill(dt);
                myConn_SQL.Dispose();
                myDa_SQL.Dispose();
                if (dt.Rows.Count > 0 && dt != null)
                {
                    return dt;
                }
                else
                {
                    dt.Dispose();
                    return null;
                }
            }
            else if (dbType == DBType.ODBC)
            {
                OdbcConnection myConn_ODBC = new OdbcConnection(csSQL);
                OdbcDataAdapter myDa_ODBC = new OdbcDataAdapter(strSql, myConn_ODBC);

                for (i = 0; i < arrParameter.Length / arrParameter.Rank; i++)
                {
                    myDa_ODBC.SelectCommand.Parameters.AddWithValue(arrParameter[i, 0], arrParameter[i, 1]);
                }
                myDa_ODBC.Fill(dt);
                myConn_ODBC.Dispose();
                myDa_ODBC.Dispose();
                if (dt.Rows.Count > 0 && dt != null)
                {
                    return dt;
                }
                else
                {
                    dt.Dispose();
                    return null;
                }
            }
            else if (dbType == DBType.MySQL)
            {
                MySql.Data.MySqlClient.MySqlConnection myConn_MySQL = new MySql.Data.MySqlClient.MySqlConnection(csSQL);
                MySql.Data.MySqlClient.MySqlDataAdapter myDa_MySQL = new MySql.Data.MySqlClient.MySqlDataAdapter(strSql, myConn_MySQL);

                for (i = 0; i < arrParameter.Length / arrParameter.Rank; i++)
                {
                    myDa_MySQL.SelectCommand.Parameters.AddWithValue(arrParameter[i, 0], arrParameter[i, 1]);
                }
                myDa_MySQL.Fill(dt);
                myConn_MySQL.Dispose();
                myDa_MySQL.Dispose();
                if (dt.Rows.Count > 0 && dt != null)
                {
                    return dt;
                }
                else
                {
                    dt.Dispose();
                    return null;
                }
            }
            else
            {
                SqlConnection myConn_SQL = new SqlConnection(csSQL);
                SqlDataAdapter myDa_SQL = new SqlDataAdapter(strSql, myConn_SQL);

                for (i = 0; i < arrParameter.Length / arrParameter.Rank; i++)
                {
                    myDa_SQL.SelectCommand.Parameters.AddWithValue(arrParameter[i, 0], arrParameter[i, 1]);
                }
                myDa_SQL.Fill(dt);
                myConn_SQL.Dispose();
                myDa_SQL.Dispose();
                if (dt.Rows.Count > 0 && dt != null)
                {
//.........这里部分代码省略.........
开发者ID:oofdui,项目名称:ChanthaburiHospital.com,代码行数:101,代码来源:clsSQL.cs

示例15: GetRealData

    /// <summary>
    /// 实时数据库的数据集
    /// </summary>
    /// <returns></returns>
    public static void GetRealData() 
    {
        //string RealConnectionSting = "DSN=FIX Dynamics Real Time Data";//实时数据库连接字符串
        string RealConnectionSting = ConfigurationSettings.AppSettings["RealDataConnectionString"];//从web.config中读出数据库连接字符串
        //string HisConnectionSting = "DSN=FIX Dynamics Historical Data";//历史数据库连接字符串
        OdbcConnection RealConnection;//实时数据库连接
        //OdbcConnection HisConnection;//历史数据库连接
        RealConnection = new OdbcConnection(RealConnectionSting);
        
        OdbcDataAdapter adapter = new OdbcDataAdapter("select A_CV from FIX", RealConnection);
        DataSet ds = new DataSet();
        RealConnection.Open();// 11.19日修改
        adapter.Fill(ds, "FIX");
        RealConnection.Close();// 11.19日修改
        adapter.Dispose();
        for (int i = 0; i < 56; i++) //将前56个点放入Boiler1数组中 模拟量
        {
            Boiler1[i] = ds.Tables[0].Rows[i]["A_CV"].ToString();
        }
        for (int i = 209; i < 220;i++ ) //从第210项开始的11个开关量送入Boiler1数组
        {
            Boiler1[i-153] = ds.Tables[0].Rows[i]["A_CV"].ToString();
        }

        for (int j = 56; j < 113; j++) //将57-113的57个点放入Boiler2数组中 模拟量
        {
            Boiler2[j-56] = ds.Tables[0].Rows[j]["A_CV"].ToString();
        }
        for (int j = 220; j < 231; j++) //从第220项开始的11个开关量送入Boiler2数组
        {
            Boiler2[j - 163] = ds.Tables[0].Rows[j]["A_CV"].ToString();
        }

        for (int k = 113; k < 189; k++) //将114-189的76个点放入Trubine数组中 模拟量
        {
            Trubine[k - 113] = ds.Tables[0].Rows[k]["A_CV"].ToString();
        }
        

        for (int m = 189; m < 209; m++) //将190-109的20个点放入DEH数组中 模拟量
        {
            DEH[m - 189] = ds.Tables[0].Rows[m]["A_CV"].ToString();
        }

        for (int k = 231; k < 247; k++) //从第232-247项的16个开关量送入Trubine数组
        {
            Trubine[k - 155] = ds.Tables[0].Rows[k]["A_CV"].ToString();
        }

        for (int H = 247; H < 250; H++) //从第248-250项的3个开关量送入DEH数组
        {
            DEH[H - 227] = ds.Tables[0].Rows[H]["A_CV"].ToString();
        }
        //for (int j = 62; j < 125; j++) //将63-125的点放入Boiler2数组中 模拟量+开关量 63个
        //{ 
        //    Boiler2[j - 62] = ds.Tables[0].Rows[j]["A_CV"].ToString();
        //}
        //for (int k = 126; k < 199; k++) // 将前126-199的点放入Trubine数组中 模拟量+开关量 74个
        //{
        //    Trubine[k - 126] = ds.Tables[0].Rows[k]["A_CV"].ToString();
        //}
        //for (int m = 200; m < 228; m++)//将前200-228的点放入DEH数组中 模拟量+开关量 29个
        //{
        //    DEH[m - 200] = ds.Tables[0].Rows[m]["A_CV"].ToString();
        //}
        //return ds;
        ds.Dispose();
    }
开发者ID:neroanelli,项目名称:DCS.Web,代码行数:72,代码来源:Data.cs


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