sqlite数据读取器 - c#

在我的C#应用​​程序中,以下代码面临问题,用于从数据库中删除项目,

if (orderedRelationSet.RemoveRelation(relation) != true)
{
    TouchServer.Log(Logger.MessageType.Error, 0,     OrderedRelationSet.error_msg + "Remove relation operation failed");
    throw new Exception("remove relation failed");
}



public bool RemoveRelation(Relation relation)
{
    Relation relationToRemove = null;
    relationToRemove = relation;

    int roweffected = 0;
    int flg_delete = 0;

    int ordinal_source = 0;

    if (relationToRemove != null)
    {

        SQLiteDataReader dr_readtype = db.ExecuteSQL("select typeid from item where id=" + relation.ThingId + "");
        try
        {
             dr_readtype.Read();
             type_id = Convert.ToInt32(dr_readtype[0]);
        }
        catch (Exception)
        {
        }
        finally
        {
            dr_readtype.Close();
            dr_readtype.Dispose();

        }

        SQLiteDataReader dr_ordinal = db.ExecuteSQL("select ordinal from relation where parent_itemid=" + relation.SourceThingId + " and child_itemid= " + relation.ThingId + ""); 
        try
        {
            dr_ordinal.Read();
            ordinal_source = Convert.ToInt32(dr_ordinal[0]); 
        }
        catch (Exception)
        {
        }
        finally
        {
            dr_ordinal.Close();
            dr_ordinal.Dispose();
        }


        if (flg_delete == 0 || db.currentUser.UserName=="System")
        {
            relations.Remove(relationToRemove);
            roweffected = relationToRemove.UnSet();

            type_id = 0;
        }
    }
    if (roweffected >= 1)
    {

        SQLiteDataReader dr_ordinal = db.ExecuteSQL("select ordinal,child_itemid from relation where parent_itemid=" + relation.SourceThingId + " and ordinal > " + ordinal_source + ""); 
        Hashtable list = new Hashtable();
        try
        {
            while (dr_ordinal.Read())
            {
                 list.Add(int.Parse(dr_ordinal[1].ToString()), int.Parse(dr_ordinal[0].ToString()));
                 //lis1.Add(int.Parse(dr_ordinal[1].ToString()));
            }
        }
        catch (Exception)
        {
        }
        finally
        {
            dr_ordinal.Close();
            dr_ordinal.Dispose()
        }
        int j = 0;
        foreach (int key in list.Keys)
        {
            int ordi = (int)list[key];
            int ordinal_result = ordi - 1;

            try
            {
                 string sqlExpr = "update relation set ordinal=@ordinal_result where parent_itemid=@relation_SourceThingId and child_itemid=@key";
                 SQLiteCommand _updateRelation = new SQLiteCommand();
                 _updateRelation.CommandText = sqlExpr;
                 _updateRelation.Parameters.AddWithValue("@ordinal_result", ordinal_result);
                _updateRelation.Parameters.AddWithValue("@relation_SourceThingId", relation.SourceThingId);
                _updateRelation.Parameters.AddWithValue("@key", key);
                int update_sql = db.ExecuteNonQuerySQL(_updateRelation);

            }
            catch (Exception)
            {
            }
            j++;

        }
        string sqlExprs = "UPDATE item SET modified =@dates,modifiedby =@currentUser WHERE id =@relation_SourceThingId";
        SQLiteCommand _updateItem = new SQLiteCommand();
        _updateItem.CommandText = sqlExprs;
        _updateItem.Parameters.AddWithValue("@dates", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
       _updateItem.Parameters.AddWithValue("@currentUser", db.currentUser.id);
       _updateItem.Parameters.AddWithValue("@relation_SourceThingId", relation.SourceThingId);
       int affect = db.ExecuteNonQuerySQL(_updateItem);

       return true;
   }
   else
   {                   
       return false;
   }

   flg_delete = 0;
}

它不删除数据。
请帮忙..

参考方案

你有很多

    catch (Exception)         {         } 

但是那里有异常文本的消息框

    catch (Exception E)         
    {
        MessageBox.Show(E.ToString());
    }

当回复有时是一个对象有时是一个数组时,如何在使用改造时解析JSON回复? - java

我正在使用Retrofit来获取JSON答复。这是我实施的一部分-@GET("/api/report/list") Observable<Bills> listBill(@Query("employee_id") String employeeID); 而条例草案类是-public static class…

Mongo汇总 - javascript

我的收藏中有以下文件{ "_id": ObjectId("54490b8104f7142f22ecc97f"), "title": "Sample1", "slug": "samplenews", "cat": …

如何在Wiremock中为JUNIT匹配精确的json - java

我正在使用Wiremock在Spring启动应用程序中模拟Junit的REST服务。我的问题是,我无法匹配多个匹配模式。 Junit.javaStringValuePattern pattern = WireMock.matching(".*"); givenThat(post(urlEqualTo("/softwares�…

如何在JQuery中操作JSONArray - javascript

我有一个php函数,它以JSON返回此代码{"0":{"title":"Dans l\u2019appartement"},"1":{"title":"A l\u2019a\u00e9roport - D\u00e9part de B\u00e9at…

如何使用C#仅从多层嵌入式MongoDB文档中获取具有相应父元素的确切子元素 - c#

尝试使用C#从嵌入式MongoDB文档中获取确切的子文档及其对应的父文档,但查询返回所有子文档以及对应的父文档和其他文档。如何将参数设置为使用Filter和findOptions获得完全匹配。我的预期结果是频道1->第1集,并且是给定ID的Child Track。这是我的代码:// Class namespace CrudWithMultilvelNe…