Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Transaction / Locking ?

Avatar of Jess31
Jess31 asked on
Microsoft SQL ServerVisual Basic.NET
12 Comments1 Solution54 ViewsLast Modified:
I have this vb.net  code that is trying to do a simple read Select outside of the Transaction. But it fails. I would think there should not be a problem do this. What am I doing wrong?
sql server database is set to compatibility 120
   myTransaction = SQLConn.BeginTransaction(IsolationLevel.ReadUncommitted)
                Dim sql As String = "Execute dbo.insertCancelInvoicePlan @InvoiceHeaderID, @PFCustomerOrderNumber"
                Using comm As New SqlCommand(sql, SQLConn)
                    comm.CommandTimeout = 300
                    comm.Transaction = myTransaction
                    For Each InvoiceHeaderID As Integer In InvoiceHeaderIDList
                        Dim CustomerOrderNumber As String = GetRandomPO(8)
                        While True
                            ' next line does a select against a table that is used in this transaction
                            If IsNewCustomerPO(CustomerOrderNumber) = True Then
                                Exit While
                            End If
                            CustomerOrderNumber = GetRandomPO(8)
                        End While
                        comm.Parameters.AddWithValue("@InvoiceHeaderID", InvoiceHeaderID)
                        comm.Parameters.AddWithValue("@PFCustomerOrderNumber", CustomerOrderNumber)
                        comm.ExecuteNonQuery()
                        comm.Parameters.Clear()
                    Next
                End Using
ASKER CERTIFIED SOLUTION
Avatar of Jess31
Jess31

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 12 Comments.
See Answers