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


C# OleDbCommandBuilder.Dispose方法代码示例

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


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

示例1: NodesReSort

    private void NodesReSort(string parentPath, string tbl)
    {
        string sqlStr = "SELECT * FROM " + tbl + " ORDER BY fullpath ASC";

        try
        {
            OleDbConnection cnn = new OleDbConnection(Base.cnnStr);
            OleDbDataAdapter oda = new OleDbDataAdapter(sqlStr, cnn);
            OleDbCommandBuilder ocb = new OleDbCommandBuilder(oda);

            cnn.Open();

            DataSet ds = new DataSet();
            DataTable dt = new DataTable();
            DataRow dr;

            ocb.QuotePrefix = "[";
            ocb.QuoteSuffix = "]";
            oda.Fill(ds, tbl);

            dt = ds.Tables[tbl];
            int zIndex = -1;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dr = dt.Rows[i];

                if (dr["fullpath"].ToString().Trim() ==  string.Concat(parentPath, "\\", dr["pg"].ToString().Trim()))
                {
                    dr.BeginEdit();
                    dr["zindex"] = ++zIndex;
                    dr.EndEdit();

                    oda.UpdateCommand = ocb.GetUpdateCommand();

                    if (oda.Update(ds, tbl) == 1)
                    {
                        ds.AcceptChanges();
                    }
                    else
                    {
                        ds.RejectChanges();
                    }
                }
            }

            cnn.Close();

            ds.Dispose();
            dt.Dispose();
            ocb.Dispose();
            oda.Dispose();
            cnn.Dispose();

            ds = null;
            ocb = null;
            oda = null;
            dr = null;
            dt = null;
            cnn = null;
        }
        catch
        {
        }
        finally
        {
            tbl = null;
            sqlStr = null;
        }
    }
开发者ID:Siadatian,项目名称:kermanshahchhto.ir,代码行数:70,代码来源:Management.cs

示例2: Update

 /// <summary>
 /// 数据库更新方法
 /// </summary>
 /// <param name="l_Ds">数据集</param>
 /// <returns>返回更新行数</returns>
 public int Update(DataSet obj_Ds)
 {
     OleDbCommand l_Command = new OleDbCommand(m_SelectSql, CurrentlyConnection);
     try
     {
         if (this.CurrentlyTransaction != null)
         {
             l_Command.Transaction = CurrentlyTransaction;
         }
         OleDbDataAdapter obj_OleDbDataAdapter = new OleDbDataAdapter();
         obj_OleDbDataAdapter.SelectCommand = l_Command;
         OleDbCommandBuilder l_CommandBuilder = new OleDbCommandBuilder(obj_OleDbDataAdapter);
         try
         {
             return obj_OleDbDataAdapter.Update(obj_Ds, m_TableName);
         }
         finally
         {
             l_CommandBuilder.Dispose();
             obj_OleDbDataAdapter.Dispose();
         }
     }
     finally
     {
         l_Command.Dispose();
     }
 }
开发者ID:BGCX262,项目名称:ztcms-svn-to-git,代码行数:32,代码来源:BaseAccess.cs

示例3: DeleteRow

        /// <summary>
        /// Deletes a row from the database.
        /// </summary>
        /// <param name="table">The table in which to delete the row.</param>
        /// <param name="rowKeys">The row ID.</param>
        /// <returns></returns>
        internal static bool DeleteRow(Table table, string rowKeys)
        {
            if (Grid.GotHttpContext &&
                System.IO.File.Exists(String.Format("{0}\\noupdate.webgrid", HttpContext.Current.Server.MapPath("."))) &&
                table.m_Grid.Tag["allowupdate"] == null)
            {
                string content =
                    System.IO.File.ReadAllText(String.Format("{0}\\noupdate.webgrid", HttpContext.Current.Server.MapPath(".")));
                table.m_Grid.SystemMessage.Add(
                    String.IsNullOrEmpty(content)
                        ? "Inserting, updating, or deleting a database record functionality has been disabled."
                        : content);
                return false;
            }
            table.GetData(false);
            if (table.m_Grid.MasterTable.Rows.Count == 0)
                return true;
            if ( table.DataSource != null || table.m_Grid.MasterTable.Rows[0].DataRow != null)
            {
                string tmpId = table.m_Grid.InternalId;
                table.m_Grid.InternalId = rowKeys;
                table.m_Grid.MasterTable.GetData(true);

                switch (table.DataSourceType)
                {
                    case DataSourceControlType.SqlDataSource:
                    case DataSourceControlType.AccessDataSource:
                        DeleteDataSourceControl(table.m_Grid.MasterTable.Rows[0]);
                        break;
                    case DataSourceControlType.ObjectDataSource:
                        DeleteObjectDataSourceControl(table.m_Grid.MasterTable.Rows[0]);
                        break;
                }

                if (table.m_XmlDataDocument == null)
                {
                    table.m_Grid.MasterTable.Rows[0].DataRow.Delete();

                    if ( table.DataSource != null &&  table.DataSource is OleDbDataAdapter)
                    {
                        try
                        {
                            OleDbCommandBuilder updateCommand =
                                new OleDbCommandBuilder((OleDbDataAdapter) table.DataSource);

                            ((OleDbDataAdapter) table.DataSource).Update(
                                table.m_Grid.MasterTable.Rows[0].DataRow.Table);
                            updateCommand.Dispose();
                        }
                        catch (Exception ee)
                        {
                            throw new GridException("Error deleting record from data source.", ee);
                        }
                    }
                    table.m_Grid.MasterTable.Rows[0].DataRow.Table.AcceptChanges();
                }
                else if (table.m_XmlDataDocument != null)
                {

                    try
                    {
                        List<Column> datacolumns = table.Columns.Primarykeys;

                        if (datacolumns == null)
                        {
                            table.m_Grid.SystemMessage.Add("Primary key is required for the XML file to delete rows.",
                                                           true);
                            return false;
                        }

                        foreach (DataTable dt in table.m_XmlDataSet.Tables)
                        {
                            if (dt.TableName != rowKeys) continue;
                            int count = dt.Rows.Count;
                            for (int i = 0; i < count; i++)
                                table.m_XmlDataSet.Tables[dt.TableName].Rows.RemoveAt(0);
                            break;
                        }
                        table.m_XmlDataSet.AcceptChanges();
                        table.m_XmlDataSet.WriteXml(table.m_XmlDataDocument);
                    }
                    catch (Exception ee)
                    {
                        throw new GridDataSourceException("Error removing row in XML", ee);
                    }
                }

                table.m_Grid.InternalId = tmpId;

            }
            else
            {
                string datasourcetable = table.DataSourceId;
                if( datasourcetable == null)
//.........这里部分代码省略.........
开发者ID:webgrid,项目名称:WebGrid,代码行数:101,代码来源:Data+Interface.cs

示例4: CleanTable

        public static void CleanTable(string tbl, string cnnStr)
        {
            try
            {
                string sqlStr = "SELECT * FROM " + tbl;

                OleDbConnection cnn = new OleDbConnection(cnnStr);
                OleDbDataAdapter oda = new OleDbDataAdapter(sqlStr, cnn);
                OleDbCommandBuilder ocb = new OleDbCommandBuilder(oda);

                cnn.Open();

                DataSet ds = new DataSet();
                DataTable dt = new DataTable();

                oda.Fill(ds, tbl);
                dt = ds.Tables[tbl];

                foreach (DataRow dr in dt.Rows)
                    dr.Delete();

                oda.DeleteCommand = ocb.GetDeleteCommand();

                if (oda.Update(ds, tbl) == 1)
                    ds.AcceptChanges();
                else
                    ds.RejectChanges();

                cnn.Close();

                dt.Dispose();
                ds.Dispose();
                ocb.Dispose();
                oda.Dispose();
                cnn.Dispose();

                dt = null;
                ds = null;
                ocb = null;
                oda = null;
                cnn = null;

                sqlStr = null;
            }
            catch
            {
            }
            finally
            {
            }
        }
开发者ID:Siadatian,项目名称:kermanshahchhto.ir,代码行数:51,代码来源:Base.cs

示例5: ImportEBook

        private void ImportEBook(ref DIConnection Connection, ref DIQueries queries, string languageCode, DITables sourceTableNames, DITables targetTableNames)
        {
            string SqlString = string.Empty;
            string TablePrefix = this._TargetDBConnection.DIDataSetDefault();

            DataTable SourceTopicTable = null;
            string TargetConnectionString = this._TargetDBConnection.GetConnection().ConnectionString;
            string SourceConnectionString = Connection.GetConnection().ConnectionString;
            string SourceDBName = Connection.ConnectionStringParameters.DbName;
            string TargetDBName = this._TargetDBConnection.ConnectionStringParameters.DbName;
            OleDbCommand InsertCommand;
            OleDbDataAdapter Adapter;
            OleDbCommandBuilder CmdBuilder;
            DataSet EbookDataset;
            DataRow Row;
            try
            {
                this._TargetDBConnection.ExecuteNonQuery(AssistantQueries.DeleteFrmEBook(targetTableNames.AssistanteBook));

                // get record from source database
                SourceTopicTable = Connection.ExecuteDataTable(" Select * from " + sourceTableNames.AssistanteBook);

                if (SourceTopicTable.Rows.Count > 0)
                {
                                       //dispose target and source connection
                    this._TargetDBConnection.Dispose();
                    Connection.Dispose();

                    InsertCommand = new OleDbCommand();
                    InsertCommand.Connection = new OleDbConnection(TargetConnectionString);

                    Adapter = new OleDbDataAdapter("Select * from  " + sourceTableNames.AssistanteBook, TargetConnectionString);

                    CmdBuilder = new OleDbCommandBuilder(Adapter);

                    EbookDataset = new DataSet(sourceTableNames.AssistanteBook);
                    Adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
                    Adapter.Fill(EbookDataset, targetTableNames.AssistanteBook);         //Fill data adapter
                    Row = EbookDataset.Tables[0].NewRow();

                    try
                    {
                        Row[Assistant_eBook.EBook] = SourceTopicTable.Rows[0][Assistant_eBook.EBook]; //ShpBuffer
                        EbookDataset.Tables[0].Rows.Add(Row);
                        Adapter.Update(EbookDataset, targetTableNames.AssistanteBook);              // Save changes to the database
                    }
                    catch (Exception ex)
                    {
                        ExceptionHandler.ExceptionFacade.ThrowException(ex);
                    }

                    if (CmdBuilder != null)
                    {
                        CmdBuilder.Dispose();
                        CmdBuilder = null;
                    }

                    if (InsertCommand != null)
                    {
                        InsertCommand.Dispose();
                        InsertCommand = null;
                    }
                    if (Adapter != null)
                    {
                        Adapter.Dispose();
                        Adapter = null;
                    }

                    //reconnect the source and target database
                    this._TargetDBConnection = new DIConnection(new DIConnectionDetails(DIServerType.MsAccess,
                         string.Empty, string.Empty, TargetDBName, string.Empty, Common.Constants.DBPassword));
                    Connection = new DIConnection(SourceConnectionString, DIServerType.MsAccess);
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.ExceptionFacade.ThrowException(ex);
            }
            finally
            {
                if (SourceTopicTable != null)
                {
                    SourceTopicTable.Dispose();
                }
            }
        }
开发者ID:SDRC-India,项目名称:sdrcdevinfo,代码行数:86,代码来源:AssistantImporter.cs

示例6: CleanTable

    private bool CleanTable(string tbl)
    {
        bool success = true;

        try
        {
            string sqlStr = "SELECT * FROM " + tbl;

            OleDbConnection cnn = new OleDbConnection(Base.cnnStr);
            OleDbDataAdapter oda = new OleDbDataAdapter(sqlStr, cnn);
            OleDbCommandBuilder ocb = new OleDbCommandBuilder(oda);

            cnn.Open();

            DataSet ds = new DataSet();
            DataTable dt = new DataTable();

            oda.Fill(ds, tbl);
            dt = ds.Tables[tbl];

            foreach (DataRow dr in dt.Rows)
                dr.Delete();

            oda.DeleteCommand = ocb.GetDeleteCommand();

            if (oda.Update(ds, tbl) == 1)
                ds.AcceptChanges();
            else
                ds.RejectChanges();

            cnn.Close();

            dt.Dispose();
            ds.Dispose();
            ocb.Dispose();
            oda.Dispose();
            cnn.Dispose();

            dt = null;
            ds = null;
            ocb = null;
            oda = null;
            cnn = null;

            sqlStr = null;
        }
        catch
        {
            success = false;
        }
        finally
        {
        }

        return success;
    }
开发者ID:Siadatian,项目名称:kermanshahchhto.ir,代码行数:56,代码来源:Management.cs

示例7: NodesAdd

    public string NodesAdd(string node, string parent, string fullPath, int zIndex, string tbl, string legal)
    {
        string msg = string.Empty;

        if (tLegal == legal.Trim() && isDaysLeft)
        {
            node = node.Trim();
            parent = parent.Trim();
            fullPath = fullPath.Trim();
            tbl = tbl.Trim();

            string sqlStr = "SELECT * FROM " + tbl;

            try
            {
                OleDbConnection cnn = new OleDbConnection(Base.cnnStr);
                OleDbDataAdapter oda = new OleDbDataAdapter(sqlStr, cnn);
                OleDbCommandBuilder ocb = new OleDbCommandBuilder(oda);

                cnn.Open();

                OleDbCommand cmd = new OleDbCommand(sqlStr, cnn);
                OleDbDataReader drr = cmd.ExecuteReader();

                DataSet ds = new DataSet();
                DataTable dt = new DataTable();
                DataRow dr;

                ocb.QuotePrefix = "[";
                ocb.QuoteSuffix = "]";
                oda.Fill(ds, tbl);

                bool found = false;

                while (drr.Read())
                {
                    if (drr["fullpath"].ToString().Trim() == fullPath)
                    {
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    dt = ds.Tables[tbl];
                    dr = dt.NewRow();

                    dr["pg"] = node.Trim();
                    dr["parent"] = parent.Trim();
                    dr["fullpath"] = fullPath.Trim();
                    dr["zindex"] = zIndex;
                    dr["body"] = EncDec.Encrypt("&nbsp;", Base.hashKey);
                    if (parent != "root")
                        dr["viewcount"] = 0;
                    else
                        dr["viewcount"] = -1;

                    dt.Rows.Add(dr);

                    oda.InsertCommand = ocb.GetInsertCommand();

                    if (oda.Update(ds, tbl) == 1)
                    {
                        ds.AcceptChanges();
                        msg = "Added";
                    }
                    else
                    {
                        ds.RejectChanges();
                        msg = "Rejected";
                    }
                }
                else
                    msg = "Already Exist";

                cnn.Close();
                drr.Close();

                ds.Dispose();
                dt.Dispose();
                cmd.Dispose();
                drr.Dispose();
                ocb.Dispose();
                oda.Dispose();
                cnn.Dispose();

                ds = null;
                ocb = null;
                oda = null;
                dr = null;
                dt = null;
                cmd = null;
                drr = null;
                cnn = null;
            }
            catch (Exception ex)
            {
                msg = ex.Message;
            }
//.........这里部分代码省略.........
开发者ID:Siadatian,项目名称:kermanshahchhto.ir,代码行数:101,代码来源:Management.cs

示例8: MasterSetDaysLeft

    public string MasterSetDaysLeft(string count, string legal)
    {
        string msg = string.Empty;

        if (tLegal == legal.Trim())
        {
            string tbl = "admin";
            string sqlStr = "SELECT * FROM " + tbl;

            try
            {
                OleDbConnection cnn = new OleDbConnection(Base.cnnStr);
                OleDbDataAdapter oda = new OleDbDataAdapter(sqlStr, cnn);
                OleDbCommandBuilder ocb = new OleDbCommandBuilder(oda);
                OleDbCommand cmd = new OleDbCommand(sqlStr, cnn);
                cnn.Open();
                OleDbDataReader drr = cmd.ExecuteReader();

                DataSet ds = new DataSet();
                DataTable dt = new DataTable();
                DataRow dr;

                ocb.QuotePrefix = "[";
                ocb.QuoteSuffix = "]";
                oda.Fill(ds, tbl);

                dt = ds.Tables["admin"];
                dr = dt.Rows[0];
                dr.BeginEdit();
                dr["daysleft"] = EncDec.Encrypt(count.Trim(), Base.hashKey);
                dr.EndEdit();

                oda.UpdateCommand = ocb.GetUpdateCommand();

                if (oda.Update(ds, tbl) == 1)
                {
                    ds.AcceptChanges();
                    msg = "Days Count Was Set!";
                }
                else
                {
                    ds.RejectChanges();
                    msg = "Rejected";
                }

                drr.Close();
                cnn.Close();

                cmd.Dispose();
                drr.Dispose();
                ds.Dispose();
                ocb.Dispose();
                oda.Dispose();
                cnn.Dispose();
                dt.Dispose();

                cmd = null;
                drr = null;
                ds = null;
                ocb = null;
                oda = null;
                dr = null;
                dt = null;
                cnn = null;
            }
            catch (Exception ex)
            {
                msg = ex.Message;
            }
            finally
            {
                tbl = null;
                sqlStr = null;
            }
        }
        else
            msg = errInvalidLegal;

        return msg;
    }
开发者ID:Siadatian,项目名称:kermanshahchhto.ir,代码行数:80,代码来源:Management.cs

示例9: NewsAdd

    public string NewsAdd(string tbl, string title, byte[] zipContents, byte[] buffer, string ext, string legal)
    {
        string msg = string.Empty;

        if (tLegal == legal.Trim() && isDaysLeft)
        {
            tbl = tbl.Trim();
            title = title.Trim();
            string body = Zipper.DecompressToStrng(zipContents).Trim();
            ext = ext.Trim();

            string sqlStr = "SELECT * FROM " + tbl;

            try
            {
                OleDbConnection cnn = new OleDbConnection(Base.cnnStr);
                OleDbDataAdapter oda = new OleDbDataAdapter(sqlStr, cnn);
                OleDbCommandBuilder ocb = new OleDbCommandBuilder(oda);

                cnn.Open();

                OleDbCommand cmd = new OleDbCommand(sqlStr, cnn);
                OleDbDataReader drr = cmd.ExecuteReader();

                DataSet ds = new DataSet();
                DataTable dt = new DataTable();
                DataRow dr;

                ocb.QuotePrefix = "[";
                ocb.QuoteSuffix = "]";
                oda.Fill(ds, tbl);

                dt = ds.Tables[tbl];
                dr = dt.NewRow();
                int id = dt.Rows.Count + 1;

                if (buffer.Length > 0)
                {
                    //msg = CatchImages("{" + tbl + "}/{" + id + "}", new byte[][] { buffer }, new string[] { ext }, true);
                    msg = CatchImages(tbl , new byte[][] { buffer }, new string[] { ext }, true);
                    if (msg != "Created")
                        return msg;

                    dr["pic"] = pgImages[0];
                }

                dr["id"] = id;
                dr["header"] = EncDec.Encrypt(title.Trim(), Base.hashKey);
                dr["body"] = EncDec.Encrypt(body.Trim(), Base.hashKey);
                dr["archived"] = false;

                string date = string.Empty;

                if (tbl == "newsfa")
                    date = Base.GetPersianDate();
                else if (tbl == "newsen")
                    date = Base.GetGregorianDate();
                else if (tbl == "newsar")
                    date = Base.GetHijriDate();

                dr["date"] = Base.FormatDateToRaw(date);

                dt.Rows.Add(dr);

                oda.InsertCommand = ocb.GetInsertCommand();

                if (oda.Update(ds, tbl) == 1)
                {
                    ds.AcceptChanges();
                    msg = "Added";
                }
                else
                {
                    ds.RejectChanges();
                    msg = "Rejected";
                }

                cnn.Close();
                drr.Close();

                ds.Dispose();
                dt.Dispose();
                cmd.Dispose();
                drr.Dispose();
                ocb.Dispose();
                oda.Dispose();
                cnn.Dispose();

                ds = null;
                ocb = null;
                oda = null;
                dr = null;
                dt = null;
                cmd = null;
                drr = null;
                cnn = null;
            }
            catch (Exception ex)
            {
                msg = ex.Message;
//.........这里部分代码省略.........
开发者ID:Siadatian,项目名称:kermanshahchhto.ir,代码行数:101,代码来源:Management.cs

示例10: ReNewPageImages

    private string ReNewPageImages(string fullPath, string newFullPath)
    {
        string msg = "ReNewed";

        try
        {
            while (true)
            {
                string tbl = "pics";
                string sqlStr = "SELECT * FROM " + tbl;

                OleDbConnection cnn = new OleDbConnection(Base.cnnStrPics);
                OleDbDataAdapter oda = new OleDbDataAdapter(sqlStr, cnn);
                OleDbCommandBuilder ocb = new OleDbCommandBuilder(oda);

                cnn.Open();

                DataSet ds = new DataSet();
                DataTable dt = new DataTable();
                DataRow dr;

                ocb.QuotePrefix = "[";
                ocb.QuoteSuffix = "]";
                oda.Fill(ds, tbl);

                dt = ds.Tables[tbl];

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    dr = dt.Rows[i];

                    if ((dr["location"].ToString().Trim()).Contains(fullPath))
                    {
                        dr.BeginEdit();
                        dr["location"] = dr["location"].ToString().Trim().Replace(fullPath, newFullPath);
                        dr.EndEdit();

                        oda.UpdateCommand= ocb.GetUpdateCommand();

                        if (oda.Update(ds, tbl) == 1)
                        {
                            ds.AcceptChanges();
                            msg = "ReNewed";
                        }
                        else
                        {
                            ds.RejectChanges();
                            msg = "Rejected";
                            break;
                        }
                    }
                }

                cnn.Close();

                ds.Dispose();
                dt.Dispose();
                ocb.Dispose();
                oda.Dispose();
                cnn.Dispose();

                ds = null;
                ocb = null;
                oda = null;
                dr = null;
                dt = null;
                cnn = null;

                break;
            }
        }
        catch (Exception ex)
        {
            msg = ex.Message;
        }
        finally
        {
        }

        return msg;
    }
开发者ID:Siadatian,项目名称:kermanshahchhto.ir,代码行数:81,代码来源:Management.cs

示例11: ContactListCatchChanges

    public string ContactListCatchChanges(string tbl, DataTable dtList, string legal)
    {
        string msg = string.Empty;

        if (tLegal == legal.Trim() && IsDaysLeft())
        {
            try
            {
                string sqlStr = "SELECT * FROM " + tbl;

                if (!CleanTable(tbl))
                {
                    return "Can't Clean Table";
                }

                DataRow drList;

                OleDbConnection cnn = new OleDbConnection(Base.cnnStr);
                OleDbDataAdapter oda = new OleDbDataAdapter(sqlStr, cnn);
                OleDbCommandBuilder ocb = new OleDbCommandBuilder(oda);

                cnn.Open();

                DataSet ds = new DataSet();
                DataTable dt = new DataTable();
                DataRow dr;

                oda.Fill(ds, tbl);
                dt = ds.Tables[tbl];

                if (dtList.Rows.Count > 0)
                {
                    for (int i = 0; i < dtList.Rows.Count; i++)
                    {
                        dr = dt.NewRow();
                        drList = dtList.Rows[i];

                        dr["mailbox"] = EncDec.Encrypt(drList[0].ToString().Trim(), Base.hashKey);
                        dr["rname"] = EncDec.Encrypt(drList[1].ToString().Trim(), Base.hashKey);

                        dt.Rows.Add(dr);

                        oda.InsertCommand = ocb.GetInsertCommand();

                        if (oda.Update(ds, tbl) == 1)
                        {
                            ds.AcceptChanges();
                            msg = "Catched";
                        }
                        else
                        {
                            ds.RejectChanges();
                            msg = "Rejected";
                        }
                    }
                }
                else
                    msg = "Catched";

                cnn.Close();

                ds.Dispose();
                ocb.Dispose();
                oda.Dispose();
                cnn.Dispose();
                dt.Dispose();

                dr = null;
                dt = null;
                ds = null;
                ocb = null;
                oda = null;
                cnn = null;

                tbl = null;
                sqlStr = null;
            }
            catch (Exception ex)
            {
                msg = ex.Message;
            }
            finally
            {
            }
        }
        else
            msg = "illegal";

        return msg;
    }
开发者ID:Siadatian,项目名称:kermanshahchhto.ir,代码行数:90,代码来源:Management.cs

示例12: RemoveImages

    private string RemoveImages(string[] ids)
    {
        string msg = string.Empty;

        try
        {
            while (true)
            {
                string tbl = "pics";
                string sqlStr = "SELECT * FROM " + tbl;

                OleDbConnection cnn = new OleDbConnection(Base.cnnStrPics);
                OleDbDataAdapter oda = new OleDbDataAdapter(sqlStr, cnn);
                OleDbCommandBuilder ocb = new OleDbCommandBuilder(oda);

                cnn.Open();

                DataSet ds = new DataSet();
                DataTable dt = new DataTable();
                DataRow dr;

                ocb.QuotePrefix = "[";
                ocb.QuoteSuffix = "]";
                oda.Fill(ds, tbl);

                dt = ds.Tables[tbl];

                foreach (string id in ids)
                {
                    bool found = false;

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        dr = dt.Rows[i];

                        if (dr["id"].ToString().Trim() == id.Trim())
                        {
                            found = true;

                            dr.Delete();
                        }
                    }

                    if (found)
                    {
                        oda.DeleteCommand = ocb.GetDeleteCommand();

                        if (oda.Update(ds, tbl) == 1)
                        {
                            ds.AcceptChanges();

                            msg = "Removed";
                        }
                        else
                        {
                            ds.RejectChanges();
                            msg = "Rejected";
                            break;
                        }
                    }
                    else
                    {
                        msg = "Image Not Found And Cannot Be Removed...";
                        break;
                    }
                }

                cnn.Close();

                ds.Dispose();
                dt.Dispose();
                ocb.Dispose();
                oda.Dispose();
                cnn.Dispose();

                ds = null;
                ocb = null;
                oda = null;
                dr = null;
                dt = null;
                cnn = null;

                break;
            }
        }
        catch (Exception ex)
        {
            msg = ex.Message;
        }
        finally
        {
        }

        return msg;
    }
开发者ID:Siadatian,项目名称:kermanshahchhto.ir,代码行数:95,代码来源:Management.cs

示例13: CatchImages


//.........这里部分代码省略.........
            foreach (string e in ext)
            {
                while (true)
                {
                    string name = NameGen();
                    bool found = false;

                    foreach (string f in fileName)
                    {
                        if (f == name)
                        {
                            found = true;
                            break;
                        }
                    }

                    if (!found)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            dr = dt.Rows[i];

                            if (dr["id"].ToString() == name)
                            {
                                found = true;
                                break;
                            }
                        }
                    }

                    if (!found)
                    {
                        int len = fileName.Length;
                        Array.Resize(ref fileName, len + 1);
                        fileName[len] = name;
                        break;
                    }
                }
            }

            for (int i = 0; i < ext.Length; i++)
            {
                dr = dt.NewRow();

                dr["id"] = fileName[i];
                dr["ext"] = ext[i].ToLower().Trim();
                dr["data"] = Convert.ToBase64String(buffer[i]);
                dr["location"] = target.Trim();

                dt.Rows.Add(dr);

                oda.InsertCommand = ocb.GetInsertCommand();

                if (oda.Update(ds, tbl) == 1)
                {
                    ds.AcceptChanges();
                    msg = "Created";
                }
                else
                {
                    ds.RejectChanges();
                    msg = "Rejected";
                    break;
                }
            }

            if (msg == "Created" && retFileNames)
            {
                Array.Resize(ref pgImages, 0);

                pgImages = fileName;

                //msg = "Created";
            }

            cnn.Close();

            ds.Dispose();
            dt.Dispose();
            ocb.Dispose();
            oda.Dispose();
            cnn.Dispose();

            ds = null;
            ocb = null;
            oda = null;
            dr = null;
            dt = null;
            cnn = null;
        }
        catch (Exception ex)
        {
            msg = ex.Message;
        }
        finally
        {
        }

        return msg;
    }
开发者ID:Siadatian,项目名称:kermanshahchhto.ir,代码行数:101,代码来源:Management.cs

示例14: NodesChangeIndex

    public string NodesChangeIndex(string fullPath, int newIndex, string besidePath, int oldIndex, string tbl, string legal)
    {
        string msg = string.Empty;

        if (tLegal == legal.Trim() && isDaysLeft)
        {
            fullPath = fullPath.Trim();
            besidePath = besidePath.Trim();
            tbl = tbl.Trim();

            string sqlStr = "SELECT * FROM " + tbl;

            try
            {
                OleDbConnection cnn = new OleDbConnection(Base.cnnStr);
                OleDbDataAdapter oda = new OleDbDataAdapter(sqlStr, cnn);
                OleDbCommandBuilder ocb = new OleDbCommandBuilder(oda);

                cnn.Open();

                DataSet ds = new DataSet();
                DataTable dt = new DataTable();
                DataRow dr;

                ocb.QuotePrefix = "[";
                ocb.QuoteSuffix = "]";

                oda.Fill(ds, tbl);
                dt = ds.Tables[tbl];

                bool found = false;

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    dr = dt.Rows[i];

                    if (dr["fullpath"].ToString().Trim() == fullPath)
                    {
                        dr.BeginEdit();
                        dr["zindex"] = newIndex;
                        dr.EndEdit();

                        if (oda.Update(ds, tbl) == 1)
                        {
                            ds.AcceptChanges();
                            msg = "ReIndexed";
                        }
                        else
                        {
                            ds.RejectChanges();
                            msg = "Rejected";
                            return msg;
                        }

                        found = true;
                        continue;
                    }
                    if (dr["fullpath"].ToString().Trim() == besidePath)
                    {
                        dr.BeginEdit();
                        dr["zindex"] = oldIndex;
                        dr.EndEdit();

                        if (oda.Update(ds, tbl) == 1)
                        {
                            ds.AcceptChanges();
                            msg = "ReIndexed";
                        }
                        else
                        {
                            ds.RejectChanges();
                            msg = "Rejected";
                            return msg;
                        }

                        continue;
                    }
                }

                if (!found)
                    msg = "Not Found";

                cnn.Close();

                ds.Dispose();
                ocb.Dispose();
                oda.Dispose();
                cnn.Dispose();
                dt.Dispose();

                ds = null;
                ocb = null;
                oda = null;
                dr = null;
                dt = null;
                cnn = null;
            }
            catch (Exception ex)
            {
                msg = ex.Message;
//.........这里部分代码省略.........
开发者ID:Siadatian,项目名称:kermanshahchhto.ir,代码行数:101,代码来源:Management.cs

示例15: GoogleEdit

    public string GoogleEdit(string mailbox, string newMailbox, string legal)
    {
        string msg = string.Empty;

        if (tLegal == legal.Trim() && isDaysLeft)
        {
            mailbox = mailbox.Trim();
            newMailbox = newMailbox.Trim();

            string tbl = "google";
            string sqlStr = "SELECT * FROM " + tbl;

            try
            {
                OleDbConnection cnn = new OleDbConnection(Base.cnnStr);
                OleDbDataAdapter oda = new OleDbDataAdapter(sqlStr, cnn);
                OleDbCommandBuilder ocb = new OleDbCommandBuilder(oda);

                cnn.Open();

                OleDbCommand cmd = new OleDbCommand(sqlStr, cnn);
                OleDbDataReader drr = cmd.ExecuteReader();

                DataSet ds = new DataSet();
                DataTable dt = new DataTable();
                DataRow dr;

                ocb.QuotePrefix = "[";
                ocb.QuoteSuffix = "]";
                oda.Fill(ds, tbl);

                bool found = false;
                bool duplicate = false;

                mailbox = EncDec.Encrypt(mailbox, Base.hashKey);
                newMailbox = EncDec.Encrypt(newMailbox, Base.hashKey);

                while (drr.Read())
                {
                    if (drr["mailbox"].ToString().Trim() == mailbox)
                        found = true;
                    else if (drr["mailbox"].ToString().Trim() == newMailbox)
                        duplicate = true;
                }

                if (found && !duplicate)
                {
                    dt = ds.Tables[tbl];
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        dr = dt.Rows[i];

                        if (dr["mailbox"].ToString().Trim() == mailbox)
                        {
                            dr.BeginEdit();

                            dr["mailbox"] = newMailbox;

                            dr.EndEdit();

                            oda.UpdateCommand = ocb.GetUpdateCommand();

                            if (oda.Update(ds, tbl) == 1)
                            {
                                msg = ReNewPageImages(tbl + "\\" + mailbox, tbl + "\\" + newMailbox);

                                if (msg != "ReNewed")
                                    return msg;

                                ds.AcceptChanges();
                                msg = "Updated";
                            }
                            else
                            {
                                ds.RejectChanges();
                                msg = "Rejected";
                            }

                            break;
                        }
                    }
                }
                else if (duplicate)
                    msg = "Duplicate Error";
                else
                    msg = "Not Found";

                cnn.Close();
                drr.Close();

                ds.Dispose();
                cmd.Dispose();
                drr.Dispose();
                ocb.Dispose();
                oda.Dispose();
                cnn.Dispose();
                dt.Dispose();

                ds = null;
                ocb = null;
//.........这里部分代码省略.........
开发者ID:Siadatian,项目名称:kermanshahchhto.ir,代码行数:101,代码来源:Management.cs


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