當前位置: 首頁>>代碼示例>>C#>>正文


C# DataTable.Dispose方法代碼示例

本文整理匯總了C#中System.Data.DataTable.Dispose方法的典型用法代碼示例。如果您正苦於以下問題:C# DataTable.Dispose方法的具體用法?C# DataTable.Dispose怎麽用?C# DataTable.Dispose使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Data.DataTable的用法示例。


在下文中一共展示了DataTable.Dispose方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: nseCompanyCodes

        public static void nseCompanyCodes()
        {
            StreamReader sr = new StreamReader(@"C:\\Documents and Settings\\Amey\\Desktop\\EQUITY_L.csv");
            DataTable nsedata = new DataTable();
            DataColumn companyName = new DataColumn("CompanyName");
            nsedata.Columns.Add(companyName);
            DataColumn nsecode = new DataColumn("NSE Code");
            nsedata.Columns.Add(nsecode);
            DataRow row;
            string[] values = null;
            sr.ReadLine();
            while (!sr.EndOfStream)
            {
                values = sr.ReadLine().Split(',');
                row = nsedata.NewRow();
                row[companyName] = values[1];
                row[nsecode] = values[0];
                nsedata.Rows.Add(row);

            }
            CommonFunctions.Write(nsedata, "nsecompanies.txt");
            sr.Close();
            nsedata.Dispose();
            companyName.Dispose();
            nsecode.Dispose();
        }
開發者ID:androidea86,項目名稱:StockQuote,代碼行數:26,代碼來源:NSECompanyCode.cs

示例2: ExecuteArrayList

        /// <summary>
        /// Execute Array List
        /// </summary>
        /// <param name="commandType">Command Type</param>
        /// <param name="mySqlList">Sql List</param>
        /// <returns></returns>
        public static ArrayList ExecuteArrayList(CommandType cmdType, List<SqlList> mySqlList)
        {
            SqlCommand cmd = new SqlCommand();
            ArrayList al = new ArrayList();
            DataTable dt = null;

            int i = 0;

            using (SqlConnection con = new SqlConnection(sqlconn))
            {
                foreach (SqlList item in mySqlList)
                {
                    PrepareCommand(cmd, con, null, cmdType, item.strSQL, item.myPrams);
                    SqlDataAdapter adp = new SqlDataAdapter(cmd);

                    try
                    {
                        dt = new DataTable();
                        adp.Fill(dt);
                        i = i + 1;
                        if (dt.Rows.Count > 0)
                            al.Add(dt.Rows[0].ItemArray);
                        dt.Dispose();
                        cmd.Parameters.Clear();
                    }
                    finally
                    {
                        adp.Dispose();
                    }
                }
            }
            return al;
        }
開發者ID:XcoderTeam,項目名稱:Transaction,代碼行數:39,代碼來源:SqlHelper.cs

示例3: AddOrder

        public void AddOrder() 
        {
            string connectionString = WebConfigurationManager.AppSettings["ConnectionString"];

            using (SqlConnection connection = new SqlConnection(connectionString))
            {

                DataTable dt = new DataTable();
                SqlCommand command = new SqlCommand(Resources.Resource.InsertOrder, connection);
                command.Parameters.AddWithValue("@ID", ID);
                command.Parameters.AddWithValue("@Cliente", Cliente);
                command.Parameters.AddWithValue("@Telefone", Telefone);
                command.Parameters.AddWithValue("@Pedido", Pedido);
                command.Parameters.AddWithValue("@DataPedido", DateTime.Now);

                try
                {
                    connection.Open();
                    command.CommandType = CommandType.Text;
                    command.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                finally
                {
                    dt.Dispose();
                    connection.Close();
                }
            }
        }
開發者ID:shidomi,項目名稱:Samples-.Net,代碼行數:32,代碼來源:Order.cs

示例4: button2_Click

        private void button2_Click(object sender, EventArgs e)
        {
            DataTable tb = new DataTable();

            SQLiteDataAdapter ad = new SQLiteDataAdapter("select distinct max(serialNo) + 1 from StockPrice", ConfigurationSettings.AppSettings["connectionString"]);

            ad.Fill(tb);
            string SerialNo = tb.Rows[0][0].ToString().Trim();
            tb.Dispose();
            tb = new DataTable();
            ad = new SQLiteDataAdapter("select StockId from Stock",ConfigurationSettings.AppSettings["connectionString"]);

            ad.Fill(tb);

            StockProcess  s = null;
            System.Threading.Thread t = null;

            foreach (DataRow r in tb.Rows)
            {
                s = new StockProcess();
                s.SerialNo = SerialNo;
                s.股票代號 = r["StockId"].ToString().Trim();
                t = new System.Threading.Thread(s.Process);
                t.Start();
                System.Threading.Thread.Sleep(200);
            }
        }
開發者ID:squallli,項目名稱:Yahoo-Finance-Managed-Wrapper-master,代碼行數:27,代碼來源:Form1.cs

示例5: QUERY_CRM041_MAIN_AND_DETL

        /// <summary>
        /// 取得 VDS_CRM_ORDER_MAIN && VDS_CRM_ORDER_DETL 的 Data
        /// </summary>
        /// <param name="ParameterList"></param>
        /// <returns>回傳查詢結果</returns>
        public DataSet QUERY_CRM041_MAIN_AND_DETL(ArrayList ParameterList)
        {
            try
            {
                DataSet ds_Return = new DataSet();
                DataTable dt_Return_Main = new DataTable();
                DataTable dt_Return_Detl = new DataTable();

                DBO.VDS_CRM_ORDER_MAINDBO VCOM = new VDS_CRM_ORDER_MAINDBO(ref USEDB);
                DBO.VDS_CRM_ORDER_DETLDBO VCOD = new VDS_CRM_ORDER_DETLDBO(ref USEDB);

                dt_Return_Main = VCOM.QUERY_CRM041_MAIN(ParameterList);
                dt_Return_Main.TableName = "VDS_CRM_ORDER_MAIN";

                dt_Return_Detl = VCOD.QUERY_CRM041_DETL(ParameterList);
                dt_Return_Detl.TableName = "VDS_CRM_ORDER_DETL";

                ds_Return.Tables.Add(dt_Return_Main.Copy());
                ds_Return.Tables.Add(dt_Return_Detl.Copy());

                dt_Return_Main.Clear();
                dt_Return_Detl.Clear();
                dt_Return_Main.Dispose();
                dt_Return_Detl.Dispose();

                return ds_Return;

            }
            catch (Exception ex)
            { throw GetNewException(ex); }
        }
開發者ID:ChiangHanLung,項目名稱:PIC_VDS,代碼行數:36,代碼來源:RecordCRMOrder.cs

示例6: btnNew_Click

        private void btnNew_Click( object sender, EventArgs e )
        {
            if( Program.UserType == UserType.Customer )
                return;

            AddDlg dlg = new AddDlg();
            if( dlg.ShowDialog( this ) != DialogResult.OK )
                return;

            RefillComboBoxes();

            OleDbCommand cmd = new OleDbCommand();
            cmd.CommandText = "select top 1 * from WedDress order by [ID] desc";
            cmd.Connection = Program.Database;
            cmd.CommandType = CommandType.Text;

            OleDbDataAdapter oda = new OleDbDataAdapter( cmd);
            DataTable dt = new DataTable();
            oda.Fill( dt );

            dsDress.Tables["WedDress"].Merge( dt );
            dt.Dispose();
            oda.Dispose();
            cmd.Dispose();
        }
開發者ID:mokacao,項目名稱:backup,代碼行數:25,代碼來源:MainForm.cs

示例7: cbp_UploadDocument_Loader_Callback

        protected void cbp_UploadDocument_Loader_Callback(object sender, DevExpress.Web.CallbackEventArgsBase e)
        {
            DataTable Dt = new DataTable();

            try
            {
                string err = DocumentUploaderMethods.DocumentInfo(RowId.Text, ref Dt);

                if (err == string.Empty)
                {
                    if (Dt.Rows.Count == 1)
                    {
                        DocumentFileUserName.Text = Dt.Rows[0]["DocumentFileUserName"].ToString();
                        UploadedBy.Text = Dt.Rows[0]["UploadedBy"].ToString();
                        Notes.Text = Dt.Rows[0]["Notes"].ToString();
                        UploadedDate.Text = Convert.ToDateTime(Dt.Rows[0]["UploadedDate"]).ToString("dd/MM/yyyy HH:mm");
                        cbp_UploadDocument_Loader.JSProperties["cpErrMsg"] = string.Empty;
                    }
                    else
                    { cbp_UploadDocument_Loader.JSProperties["cpErrMsg"] = "Sistem tidak dapat membuka info gambar yang telah dipilih."; }
                }
                else
                { cbp_UploadDocument_Loader.JSProperties["cpErrMsg"] = err; }
            }
            catch (Exception err)
            {
                cbp_UploadDocument_Loader.JSProperties["cpErrMsg"] = err.Message;
            }
            finally
            { Dt.Dispose(); }
        }
開發者ID:safaintegrated,項目名稱:asm,代碼行數:31,代碼來源:UploadDocument_Controller.ascx.cs

示例8: AddInfoModel

 public int AddInfoModel(DataTable dt, string TableName)
 {
     int num;
     string str = "";
     string str2 = "";
     for (num = 0; num < dt.Rows.Count; num++)
     {
         if ((dt.Rows.Count - 1) == num)
         {
             str = str + "[" + dt.Rows[num]["FieldName"].ToString() + "])";
             str2 = str2 + "@" + dt.Rows[num]["FieldName"].ToString() + ");select scope_identity()";
         }
         else
         {
             str = str + "[" + dt.Rows[num]["FieldName"].ToString() + "],";
             str2 = str2 + "@" + dt.Rows[num]["FieldName"].ToString() + ",";
         }
     }
     StringBuilder builder = new StringBuilder();
     builder.Append("insert into " + TableName + "(");
     builder.Append(str);
     builder.Append(" values (");
     builder.Append(str2);
     SqlParameter[] commandParameters = new SqlParameter[dt.Rows.Count];
     for (num = 0; num < dt.Rows.Count; num++)
     {
         commandParameters[num] = new SqlParameter("@" + dt.Rows[num]["FieldName"].ToString(), dt.Rows[num]["FieldValue"].ToString());
     }
     int num2 = Convert.ToInt32(SqlHelper.ExecuteScalar(SqlHelper.ConnectionStringKy, CommandType.Text, builder.ToString(), commandParameters));
     dt.Clear();
     dt.Dispose();
     return num2;
 }
開發者ID:suizhikuo,項目名稱:KYCMS,代碼行數:33,代碼來源:InfoModel.cs

示例9: RetriveTaxesByType

        public static async Task<List<double>> RetriveTaxesByType(string taxName)
        {
            List<double> taxList = new List<double>();
            string sqlCmdString = "Select tax_amount From dbo.taxes Where [email protected]_name";
            Database myDb = new Database();
            SqlCommand sqlCmd = new SqlCommand(sqlCmdString, myDb.Connection);
            SqlDataAdapter sqlAdapt = new SqlDataAdapter(sqlCmd);
            DataTable table = new DataTable();
            double tax;

            await Task.Run(() =>
            {
                try
                {
                    myDb.OpenConnection();
                    sqlCmd.Parameters.Add(new SqlParameter("@tax_name", taxName));
                    sqlAdapt.Fill(table);

                    foreach (DataRow row in table.Rows)
                    {
                        tax = Convert.ToDouble(row["tax_amount"]);
                        taxList.Add(tax);
                    }
                }
                finally
                {
                    sqlAdapt.Dispose();
                    table.Dispose();
                    myDb.CloseConnection();
                }
            });
            
            return taxList;
        }
開發者ID:sauravdebp,項目名稱:AE-Manager,代碼行數:34,代碼來源:Tax.cs

示例10: GetQueryResults

        public static DataRowCollection GetQueryResults(string query, Dictionary<string, object> parameters, bool log = true)
        {
            DataRowCollection retResults;

            using(SqlConnection s = GetActiveConnection())
            {
                SqlCommand sQuery = new SqlCommand();
                sQuery.Connection = s;
                sQuery.CommandText = query;
                sQuery.CommandType = CommandType.Text;

                foreach(KeyValuePair<string, object> i in parameters)
                {
                    sQuery.Parameters.AddWithValue(i.Key, i.Value);
                }

                SqlDataReader sReader = sQuery.ExecuteReader();
                DataTable dTable = new DataTable();

                dTable.Load(sReader);
                retResults = dTable.Rows;

                sReader.Close();
                dTable.Dispose();
            }

            if(log) Logging.Log("Query {0} successfully executed ({1} Parameters)", query, parameters.Count);
            return retResults;
        }
開發者ID:m-windle,項目名稱:PoS-System,代碼行數:29,代碼來源:DatabaseController.cs

示例11: cbp_SaveOrg_Callback

        protected void cbp_SaveOrg_Callback(object sender, CallbackEventArgsBase e)
        {
            FormsIdentity id = (FormsIdentity)HttpContext.Current.User.Identity;
            FormsAuthenticationTicket ticket = id.Ticket;

            if (!ticket.Expired)
            {
                DataTable Dt = new DataTable();

                try
                {
                    FormTVP(ref Dt);
                    PopulateTVP(ref Dt);

                    string err = OrganisasiMethods.SP_LoadUpdate_Organisation(ref Dt, ticket.Name, "SAVE");

                    if (err == "")
                    { cbp_SaveOrg.JSProperties["cpErrMsg"] = string.Empty; }
                    else
                    { cbp_SaveOrg.JSProperties["cpErrMsg"] = ConfigurationManager.AppSettings["ErrorMessageStaringSentenceDBError"].ToString() + " " + err; }
                }
                catch (Exception err)
                { cbp_SaveOrg.JSProperties["cpErrMsg"] = ConfigurationManager.AppSettings["ErrorMessageStaringSentenceCaughtByExceptions"].ToString() + " " + err.Message; }
                finally
                { Dt.Dispose(); }
            }
            else
            { cbp_SaveOrg.JSProperties["cpErrMsg"] = "Session Expired."; }
        }
開發者ID:safaintegrated,項目名稱:asm,代碼行數:29,代碼來源:Organisasi_Controller.ascx.cs

示例12: AddIventoryItem

        public void AddIventoryItem()
        {
            string connectionString = WebConfigurationManager.AppSettings["ConnectionString"];

            using (SqlConnection connection = new SqlConnection(connectionString))
            {

                DataTable dt = new DataTable();
                SqlCommand command = new SqlCommand(Resources.Resource.AddOnInventory, connection);
                command.Parameters.AddWithValue("@Categoria", Categoria);
                command.Parameters.AddWithValue("@NomeFornecedor", NomeFornecedor);
                command.Parameters.AddWithValue("@NumeroDoc", NumeroDoc);
                command.Parameters.AddWithValue("@NomeProduto", NomeProduto);
                command.Parameters.AddWithValue("@Valor", Valor);
                command.Parameters.AddWithValue("@Observacao", Observacao);
                command.Parameters.AddWithValue("@DataCriacao", DateTime.Now);

                try
                {
                    connection.Open();
                    command.CommandType = CommandType.Text;
                    command.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                finally
                {
                    dt.Dispose();
                    connection.Close();
                }
            }
        }
開發者ID:shidomi,項目名稱:Samples-.Net,代碼行數:34,代碼來源:Inventory.cs

示例13: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            #region 標簽信息
            string strTagInfo = "";

            try
            {
                string sql = "select * from [tb_tag] where tag_ispublic=1";
                DataTable dt = new DataTable();
                DBHelper dbh = new DBHelper(config.DBConn);
                dt = dbh.ExecuteDataTable("", sql);

                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        strTagInfo += "<a href=\"default.aspx?id=" + dt.Rows[i]["tag_id"].ToString() + "\" class=\"tag\" target=\"_blank\">" + dt.Rows[i]["tag_name"].ToString() + "</a>";
                    }
                }

                dbh.Dispose();
                dt.Dispose();
            }
            catch (Exception ex)
            {
                strTagInfo = ex.ToString();
            }

            this.tagBall.InnerHtml = strTagInfo;

            #endregion
        }
開發者ID:juxiaoqi,項目名稱:LongmaoSite,代碼行數:32,代碼來源:tags.aspx.cs

示例14: GetCustomerByID

        public DataTable GetCustomerByID(int id)
        {
            string connectionString = WebConfigurationManager.AppSettings["ConnectionString"];

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                DataTable dt = new DataTable();
                SqlCommand command = new SqlCommand(Resources.Resource.GetCustomerByID, connection);
                command.Parameters.AddWithValue("@id", id);

                try
                {
                    connection.Open();
                    SqlDataReader reader = command.ExecuteReader();

                    dt.Load(reader);

                    return dt;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                finally
                {
                    dt.Dispose();
                    connection.Close();
                }

                return null;
            }
        }
開發者ID:shidomi,項目名稱:Samples-.Net,代碼行數:32,代碼來源:Customer.cs

示例15: Loaddata

 public void Loaddata()
 {
     try
     {
         ConnectDB.MoKetNoi();
         da = new SqlDataAdapter("select * from GroupClothes", ConnectDB.connect);
         dt = new DataTable();
         da.Fill(dt);
         if (dt.Rows.Count > 0)
         {
             grvgroupclothes.DataSource = dt;
             grvgroupclothes.DataBind();
         }
         else
         {
             lblerror.Text = "Loi";
         }
     }
     catch (Exception ex)
     {
         lblerror.Text = "Loi" + ex.Message;
     }
     finally
     {
         ConnectDB.DongKetNoi();
         da.Dispose();
         dt.Dispose();
     }
 }
開發者ID:DatDaiGia,項目名稱:SPM,代碼行數:29,代碼來源:GroupClothes_Control.ascx.cs


注:本文中的System.Data.DataTable.Dispose方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。