Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7670303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:47:27+00:00 2026-05-31T15:47:27+00:00

In my c# appliaction am facing problem in below code,for deleting items from database,

  • 0

In my c# appliaction am facing problem in below code,for deleting items from database,

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;
}

Its not deleting the data..
Please help..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T15:47:28+00:00Added an answer on May 31, 2026 at 3:47 pm

    You have many

        catch (Exception)         {         } 
    

    But messagebox with Exception text in there

        catch (Exception E)         
        {
            MessageBox.Show(E.ToString());
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I a using below code for Single Sign out, http://netpl.blogspot.com/2010/12/wif-ws-federation-and-single-sign-out.html Problem which i am
I am facing problem in accessing database file when I am running it on
When facing the problem of validating a property in a JSF2 application there are
I'm facing a problem when I need to distribute my java application, created using
I am working on android chat application. I am facing a problem in send
I'm facing a problem using ExtJS4. My application has a tree containing a string
I am working on one application, i am facing one problem on Internet Explorer
I am facing quite a strange problem at the moment, I have wordpress and
I have an application that uses UIDatePicker & I am facing problem as described
I am currently working on a project and facing a problem with a task.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.