[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.6

OleDb Transaction

Asked by ayha1999 in Programming for ASP.NET

Tags: set

Hi,

When I try to update different tables using Transaction I get the following error;

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:
Line 335:                    InTrans.Rollback()

update sub;

Dim InCommand As Data.OleDb.OleDbCommand = Con.CreateCommand()
Dim InTrans As Data.OleDb.OleDbTransaction

            If Con.State <> ConnectionState.Open Then
                Con.Open()
            End If

            Try
                rdr = cmd1.ExecuteReader

                If rdr.Read Then
                    NewTotalIN = rdr.Item("TotalIN")
                    If NewTotalIN = "" Or IsDBNull(NewTotalIN) Or Not IsNumeric(NewTotalIN) Then NewTotalIN = 0
                    Response.Write(NewTotalIN)
                End If
                rdr.Close()

                rdr = cmd2.ExecuteReader
                If rdr.Read Then
                    sum1 = rdr.Item("TotalOUT")
                    If sum1 = "" Or IsDBNull(sum1) Or Not IsNumeric(sum1) Then sum1 = 0
                End If
                rdr.Close()

                rdr = cmd3.ExecuteReader
                If rdr.Read Then
                    sum2 = rdr.Item("TotalOUT2")
                    If sum2 = "" Or IsDBNull(sum2) Or Not IsNumeric(sum2) Then sum2 = 0
                End If
                rdr.Close()

                rdr = cmd4.ExecuteReader
                If rdr.Read Then
                    txtROL = rdr.Item("ROL")
                    If txtROL = "" Or IsDBNull(txtROL) Or Not IsNumeric(txtROL) Then txtROL = 0
                End If
                rdr.Close()

                rdr = cmd5.ExecuteReader
                If rdr.Read Then
                    txtOldQtyIN = rdr.Item("QtyIn")
                    If txtOldQtyIN = "" Or IsDBNull(txtOldQtyIN) Or Not IsNumeric(txtOldQtyIN) Then txtOldQtyIN = 0
                End If
                rdr.Close()

                If ((NewTotalIN) - (txtOldQtyIN) + txtQtyIn) < ((sum1) + ((sum2) + txtROL)) Then
                    Response.Write("<script language='JavaScript'>alert('You cannot update.');</script>")
                    found = 1
                End If

                If found = 0 Then

                    InTrans = Con.BeginTransaction()
                    InCommand.Connection = Con
                    InCommand.Transaction = InTrans

                    InCommand.CommandText = UpdateStr1
                    InCommand.ExecuteNonQuery()

                    InCommand.CommandText = UpdateStr2
                    InCommand.ExecuteNonQuery()

                    Response.Write("<script language='JavaScript'>alert('Spare Parts IN updated successfully!');</script>")

                        InTrans.Commit()
                End If

            Catch ex1 As Exception
                Try
                    InTrans.Rollback()
                Catch ex As OleDbException
                    If Not InTrans.Connection Is Nothing Then
                        Console.WriteLine("An exception of type " & ex.GetType().ToString & _
                                          " was encountered while attempting to roll back the transaction.")
                    End If
                End Try

                'Catch ex As OleDbException
                Console.WriteLine("An exception of type " & e.GetType().ToString() & _
                            "was encountered while inserting the data.")
                Console.WriteLine("Neither record was written to database.")
            Finally
                Con.Close()
            End Try

can anyone pls. help me to solve the problem?

ayha
[+][-]01/29/05 09:34 AM, ID: 13172281Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Programming for ASP.NET
Tags: set
Sign Up Now!
Solution Provided By: shovavnik
Participating Experts: 2
Solution Grade: A
 
[+][-]01/29/05 04:47 AM, ID: 13171270Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/29/05 04:47 AM, ID: 13171272Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/29/05 08:13 AM, ID: 13171981Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/29/05 08:40 AM, ID: 13172093Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/29/05 08:48 AM, ID: 13172121Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/29/05 08:59 AM, ID: 13172172Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/29/05 09:07 AM, ID: 13172194Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/30/05 05:15 AM, ID: 13175639Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/30/05 05:45 AM, ID: 13175694Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92