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 993959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:30:21+00:00 2026-05-16T06:30:21+00:00

I am encountering a strange problem when attempting to execute a DELETE query agains

  • 0

I am encountering a strange problem when attempting to execute a DELETE query agains a SQL Server table using VB.NET, SQL Command, and Parameters.

I have the following code:

Try    
    sqlCommand.Transaction = transaction1
    sqlCommand.Connection = conn
    sqlCommand.CommandText = sqlQuery
    sqlCommand.Parameters.Add("@userID", SqlDbType.Int).Value = Convert.ToInt32(userID)
    sqlCommand.Parameters.Add("@groupID", SqlDbType.Int).Value = Convert.ToInt32(groupID)
    ''#Delete the user from the group.
    MessageBox.Show("User: " + Convert.ToString(userID) + "    Group: " + Convert.ToString(groupID))
    MessageBox.Show("Param, UserID: " + sqlCommand.Parameters.Item(0).Value.ToString)
    MessageBox.Show("Param, GroupID: " + sqlCommand.Parameters.Item(1).Value.ToString)
    return_deleteUser = sqlCommand.ExecuteNonQuery()
Catch ex As Exception
    transaction1.Rollback()
    Dim hr As Integer = Marshal.GetHRForException(ex)
    MsgBox("Removal of user from group has failed: " + ex.Message() & hr)
End Try

Which executes the following SQL Query:

Dim sqlQuery As String = "DELETE FROM MHGROUP.GROUPMEMS WHERE USERNUM =@userID AND GROUPNUM =@groupID"

My problem is that when the code executes, there is no error reported at all. I have ran SQL Profiler and the query doesn’t appear in the trace list. The three messageboxes that I have added all return the correct values, and if I was to execute the SQL query against the table with the values the query succeeds. Both the userID and groupID are 3-digit integers.

Can anyone suggest why the code is not working as intended, or any further debugging that I can use to step through the code? Ideally I would love to see the completed SQL query with the parameters completed, but I haven’t found out how to do this.

EDIT:
I have the following later in the code to check if the execute’s all processed successfully:

If return_insertEvent > 0 And return_updateUser > 0 And return_nextSID > 0 And return_deleteUser > 0 Then
    MessageBox.Show("Success")
    return_removeADGroup = RemoveUserFromGroup(userID, groupName)
    MessageBox.Show("Remove FS User from AD Group: " + return_removeADGroup)
    transaction1.Commit()
    transaction2.Commit()
    transaction3.Commit()
    transaction4.Commit()
    returnResult = 1
Else
    transaction1.Rollback()
    transaction2.Rollback()
    transaction3.Rollback()
    transaction4.Rollback()
    returnResult = 0
End If

If you require any further information please don’t hesitate in contacting me.

  • 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-16T06:30:22+00:00Added an answer on May 16, 2026 at 6:30 am

    You are missing a Transaction.Commit

    Update in respone to additional info added to question:

    Why do you have 4 transactions? Since their commit and rollbacks are all executed together, you only need one transaction. I suggest you use a TransactionScope

    You can assign the current transaction to ADO.NET Command objects:

    ADO.NET and System.Transactions

    Transaction Processing in ADO.NET 2.0

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 490k
  • Answers 490k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer First of all, it's a really bad idea to use… May 16, 2026 at 9:17 am
  • Editorial Team
    Editorial Team added an answer If you are not dead set on using a listbox,… May 16, 2026 at 9:17 am
  • Editorial Team
    Editorial Team added an answer killproc will terminate programs in the process list which match… May 16, 2026 at 9:17 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm encountering a strange problem with the session using GXT 2.1 and a Grails
I'm encountering a very strange problem: my delete actions in rails don't work anymore.
I am encountering a strange javascript regex problem on Firefox 3.6 and Chrome 6
I'm writing some mail-processing software in Python that is encountering strange bytes in header
I am encountering a strange issue with the commons-io/java-io. Essentially my file creation is
I am using JPA with Hibernate underneath, and I am having trouble getting merge
I'm having a problem with XSL variables. I know that once declared, the value
I am seeing a very strange issue with a simple controller method. Either I
Ok, this is a curly one. I'm working on some Delphi code that I
I set up all my certificates and keys today and am trying to run

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.