I am using Visual Studio 2010 for development.
This is a web application using asp.net and vb.net with MS SQL Server 2005 for the database.

I'm having some issues with inserted data being overwritten by the next transaction (if done within a relatively short amount of time, say, roughly several seconds).

I believe this may be related to how I'm exectuing the SQL in code. I have posted below an example of how I'm connecting. My concern is that this is not the correct way to do this. I am using a stored procedure to insert the data, but it does not seem to be the problem, because I have no issues when executing the commands simultaneously using SQL Managment Studio.

Is this an issue with all of the commands using the web.config file's connection string?
Is it an issue with the code I'm using to connect?

Thank You,
JTok

Sub InsertCheckOut()

        Dim InsertQuery As String = "INSERT USING STORED PROCEDURE"

        'Conn.ConnectionString points to the webconfig file's connection string
        Using myConnection As New System.Data.SqlClient.SqlConnection(Conn.ConnectionString)

            Using myCommand As New System.Data.SqlClient.SqlCommand(InsertQuery, myConnection)

                Dim retvalue As Integer

                myConnection.Open()

                retvalue = myCommand.ExecuteNonQuery()

                Console.WriteLine(retvalue)

            End Using

        End Using

    End Sub

What we would need to see (since what you're using is a stored procedure for your inserts) is the Stored Proc you're using.

The above code shows a call to the Stored Proc but nothing of the proc itself which makes it impossible for anyone to determine if there are errors in the proc that might result in row overwrites.

I have included the stored procedure, and the way I retrieve some guids for use with it.

Out of curiosity... Why do you feel the stored procedure may still be the cause of my problems, if the overwriting only seems to happen when done through my web application and not when executed directly from two sql server management windows?

Thank You for Your Help,
JTok


Here is an example of how the GUIDs/IDs are collected for use with the stored procedure:

Using Conn As New SqlConnection With {.ConnectionString = ConfigurationManager.ConnectionStrings("ConnName").ConnectionString}
            Using cmdSelect As New SqlCommand(QueryString, Conn)
                Conn.Open()

                Using dtrReader As SqlDataReader = cmdSelect.ExecuteReader
                    If dtrReader.HasRows Then
                        While dtrReader.Read
                            If dtrReader.IsDBNull(0) Then
                                Return QueryExecute
                            Else
                                QueryExecute = (dtrReader(SearchString)).ToString
                                Return QueryExecute
                            End If
                        End While
                    End If

                End Using
            End Using
        End Using

And here is the stored procedure:

USE DatabaseName;
Go

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

DROP PROCEDURE sp_StoredProc
Go

CREATE PROCEDURE sp_StoredProc
	
	--GUIDs
	@CallListID uniqueidentifier,
	@CustGUID uniqueidentifier,
	@SysGUID uniqueidentifier,
	@LogonGUID uniqueidentifier,
	
	@ProbID uniqueidentifier,
	
	@PrtID1 uniqueidentifier,
	@PrtID2 uniqueidentifier,
	@PrtID3 uniqueidentifier,
	@PrtID4 uniqueidentifier,
	
	--Employee
	@ProblemOPENEDBY_EMPLOYEE_ID char(10),
	
	--Customer	
	@CustCompany nvarchar(50),
	@CustFirstName nvarchar(50),
	@CustLastName nvarchar(50),
	
	@CustFirstPhone char(15),
	@CustSecondPhone char(15),
	@CustThirdPhone char(15),
	@CustEMailAddress nvarchar(50),
	
	@CustCity nvarchar(50),
	@CustState char(2),
	
	--System
	@BLHComputerPurchase bit,
	
	@Serial nvarchar(26),
	@SystemTypeID uniqueidentifier,
	@ModelID uniqueidentifier,
	@OSID uniqueidentifier,
	@ProblemWarranty bit,
	
	@ProblemSystemPowerCord bit,
	@ProblemSystemCase bit,
	
	@SystemUserName nvarchar(40),
	@SystemPassword nvarchar(40),
	@InternetUserName nvarchar(40),
	@InternetPassword nvarchar(40),
	
	--Problem
	@ProblemOpenedDate datetime,
	@ProblemDescription nvarchar(1000),
	@ProblemComments nvarchar(1000),
	@ProblemBenchNumber char(3),
	@ProblemSTATUS_ID uniqueidentifier,
	@ProblemSTORE_ID int,
	
	@ProblemPRIORITY_ID uniqueidentifier,
	@ProblemBACKUP_ID uniqueidentifier,
	@ProblemDueDate datetime,
	
	@PickupSTORE_ID int,
	
	--Part
	@PartDescription1 nvarchar(100),
	@PartCost1 money,
	@PartCharge1 money,
	@PartOrderedFrom1 nvarchar(40),
	@PartOrderNumber1 nvarchar(20),
	@Part1Paid bit,
	
	@PartDescription2 nvarchar(100),
	@PartCost2 money,
	@PartCharge2 money,
	@PartOrderedFrom2 nvarchar(40),
	@PartOrderNumber2 nvarchar(20),
	@Part2Paid bit,
	
	@PartDescription3 nvarchar(100),
	@PartCost3 money,
	@PartCharge3 money,
	@PartOrderedFrom3 nvarchar(40),
	@PartOrderNumber3 nvarchar(20),
	@Part3Paid bit,
	
	@PartDescription4 nvarchar(100),
	@PartCost4 money,
	@PartCharge4 money,
	@PartOrderedFrom4 nvarchar(40),
	@PartOrderNumber4 nvarchar(20),
	@Part4Paid bit,
	
	--Problem/Task
	@ProblemNote nvarchar(1000),
	@ProblemCompletedDate datetime,
	
	--Tasks
	@TaskValueBoolean1 bit=0,
	@TaskEMPLOYEE_ID1 char(10)=NULL,

	@TaskValueBoolean2 bit=0,
	@TaskEMPLOYEE_ID2 char(10)=NULL,

	@TaskValueBoolean3 bit=0,
	@TaskEMPLOYEE_ID3 char(10)=NULL,

	@TaskValueNumber4 decimal(10)=NULL,
	@TaskValueBoolean4 bit=0,
	@TaskEMPLOYEE_ID4 char(10)=NULL,

	@TaskValueNumber5 decimal(10)=NULL,
	@TaskValueBoolean5 bit=0,
	@TaskEMPLOYEE_ID5 char(10)=NULL,
	
	@TaskValueBoolean6 bit=0,
	@TaskEMPLOYEE_ID6 char(10)=NULL,

	@TaskValueNumber7 decimal(10)=NULL,
	@TaskValueBoolean7 bit=0,
	@TaskEMPLOYEE_ID7 char(10)=NULL,
	
	@TaskValueNumber8 decimal(10)=NULL,
	@TaskValueBoolean8 bit=0,
	@TaskEMPLOYEE_ID8 char(10)=NULL,
	
	@TaskValueNumber9 decimal(10)=NULL,
	@TaskValueBoolean9 bit=0,
	@TaskEMPLOYEE_ID9 char(10)=NULL,
	
	@TaskValueNumber10 decimal(10)=NULL,
	@TaskValueBoolean10 bit=0,
	@TaskEMPLOYEE_ID10 char(10)=NULL,
	
	@TaskValueNumber11 decimal(10)=NULL,
	@TaskValueBoolean11 bit=0,
	@TaskEMPLOYEE_ID11 char(10)=NULL,
	
	@TaskValueNumber12 decimal(10)=NULL,
	@TaskValueBoolean12 bit=0,
	@TaskEMPLOYEE_ID12 char(10)=NULL,
	
	@TaskValueNumber13 decimal(10)=NULL,
	@TaskValueBoolean13 bit=0,
	@TaskEMPLOYEE_ID13 char(10)=NULL,
	
	@TaskValueBoolean14 bit=0,
	@TaskEMPLOYEE_ID14 char(10)=NULL,
	
	@TaskValueNumber15 decimal(10)=NULL,
	@TaskValueBoolean15 bit=0,
	@TaskEMPLOYEE_ID15 char(10)=NULL,
	
	@TaskValueBoolean16 bit=0,
	@TaskEMPLOYEE_ID16 char(10)=NULL,

	@TaskValueNumber17 decimal(10)=NULL,
	@TaskValueBoolean17 bit=0,
	@TaskEMPLOYEE_ID17 char(10)=NULL,
	
	@TaskValueBoolean18 bit=0,
	@TaskEMPLOYEE_ID18 char(10)=NULL,
	
	@TaskValueBoolean19 bit=0,
	@TaskEMPLOYEE_ID19 char(10)=NULL,
	
	@TaskValueBoolean20 bit=0,
	@TaskEMPLOYEE_ID20 char(10)=NULL,
	
	@TaskValueBoolean21 bit=0,
	@TaskEMPLOYEE_ID21 char(10)=NULL,
	
	@TaskValueBoolean22 bit=0,
	@TaskEMPLOYEE_ID22 char(10)=NULL,
	
	@TaskValueBoolean23 bit=0,
	@TaskEMPLOYEE_ID23 char(10)=NULL,
	
	@TaskValueBoolean24 bit=0,
	@TaskEMPLOYEE_ID24 char(10)=NULL,
	
	@TaskValueBoolean25 bit=0,
	@TaskEMPLOYEE_ID25 char(10)=NULL,
	
	@TaskValueBoolean26 bit=0,
	@TaskEMPLOYEE_ID26 char(10)=NULL,
	
	@TaskValueBoolean27 bit=0,
	@TaskEMPLOYEE_ID27 char(10)=NULL,
	
	--Charges
	@ServiceID1 uniqueidentifier,
	@ChargeOverride1 bit,
	@ChargeAmount1 money,
	@ServiceID2 uniqueidentifier,
	@ChargeOverride2 bit,
	@ChargeAmount2 money,
	@ServiceID3 uniqueidentifier,
	@ChargeOverride3 bit,
	@ChargeAmount3 money,
	@ServiceID4 uniqueidentifier,
	@ChargeOverride4 bit,
	@ChargeAmount4 money,
	@ServiceID5 uniqueidentifier,
	@ChargeOverride5 bit,
	@ChargeAmount5 money,
	@Service1Paid bit,
	@Service2Paid bit,
	@Service3Paid bit,
	@Service4Paid bit,
	@Service5Paid bit,
	
	--Problem/Finish/Called
	@FirstCall bit,
	@FirstCallDT datetime




AS
BEGIN
	SET NOCOUNT ON;
	
	--Sets email address to null if necessary
	If @CustEMailAddress = 'na@na.com'
		Select @CustEMailAddress = NULL

	--Updates customer table
	Update CUSTOMER
	Set Company = @CustCompany, FirstName = @CustFirstName, LastName = @CustLastName, FirstPhone = @CustFirstPhone, SecondPhone = @CustSecondPhone, ThirdPhone = @CustThirdPhone, EMailAddress = @CustEMailAddress, City = @CustCity, [State] = @CustState
	Where CUSTOMERGUID = @CustGUID

	--Updates logon table
	Update LOGON
	Set SystemUserName = @SystemUserName, SystemPassword = @SystemPassword, InternetUserName = @InternetUserName, InternetPassword = @InternetPassword
	Where LOGONGUID = @LogonGUID

    --Updates system table
	Update [SYSTEM]
	Set BLHComputerPurchase = @BLHComputerPurchase, SYSTEM_TYPEGUID = @SystemTypeID, MODELGUID = @ModelID, OSGUID = @OSID, LOGONGUID = @LogonGUID, Serial = @Serial
	Where SYSTEMGUID = @SysGUID
	
	--Inserts call data
	INSERT INTO CALL_LIST (CALL_LISTGUID,FirstCall,FirstCallDT)
	Values(@CallListID,@FirstCall,@FirstCallDT)
	
	--Updates problem table
	Update PROBLEM
	Set [Description] = @ProblemDescription, BenchNumber = @ProblemBenchNumber, OpenedDate = @ProblemOpenedDate, DueDate = @ProblemDueDate, Comments = @ProblemComments, Warranty = @ProblemWarranty, SystemPowerCord = @ProblemSystemPowerCord, SystemCarryBag = @ProblemSystemCase, OPENEDBY_EMPLOYEE_ID = @ProblemOPENEDBY_EMPLOYEE_ID, STATUSGUID = @ProblemSTATUS_ID, PRIORITYGUID = @ProblemPRIORITY_ID, SYSTEMGUID = @SysGUID, STORE_ID = @ProblemSTORE_ID,	BACKUPGUID = @ProblemBACKUP_ID, Note = @ProblemNote, CompletedDate = @ProblemCompletedDate, CALL_LISTGUID = @CallListID
	Where PROBLEMGUID = @ProbID
	
	--Updates part data for up to four different parts
	DECLARE @PartID1 uniqueidentifier
	If @PrtID1 IS NOT NULL AND @PartDescription1 IS NOT NULL AND @PartCost1 IS NOT NULL
BEGIN
		Update PART
		Set PartDescription = @PartDescription1, PartCost = @PartCost1, PartCharge = @PartCharge1, OrderedFrom = @PartOrderedFrom1, OrderNumber = @PartOrderNumber1, Paid = @Part1Paid
		Where PARTGUID = @PrtID1
		Select @PartID1=@PrtID1
END
	Else If @@ROWCOUNT = 0 AND @PrtID1 IS NULL AND @PartDescription1 IS NOT NULL AND @PartCost1 IS NOT NULL
BEGIN
		Select @PartID1=newid()
		Insert PART (PARTGUID,PartDescription,PartCost,PartCharge,OrderedFrom,OrderNumber,Paid) Values(@PartID1,@PartDescription1,@PartCost1,@PartCharge1,@PartOrderedFrom1,@PartOrderNumber1,@Part1Paid)
		Insert PROBLEM_PART Values(@ProbID,@PartID1)
END
	Else If @@ROWCOUNT = 0 AND @PrtID1 IS NOT NULL AND @PartDescription1 IS NULL
BEGIN
		Delete From PROBLEM_PART Where PROBLEM_PROBLEMGUID = @ProbID AND PART_PARTGUID = @PrtID1
		Delete From PART Where PARTGUID = @PrtID1
		Select @PartID1=@PrtID1
END

	DECLARE @PartID2 uniqueidentifier
	If @PrtID2 IS NOT NULL AND @PartDescription2 IS NOT NULL AND @PartCost2 IS NOT NULL
BEGIN
		Update PART
		Set PartDescription = @PartDescription2, PartCost = @PartCost2, PartCharge = @PartCharge2, OrderedFrom = @PartOrderedFrom2, OrderNumber = @PartOrderNumber2, Paid = @Part2Paid
		Where PARTGUID = @PrtID2
		Select @PartID2=@PrtID2
END
	Else If @@ROWCOUNT = 0 AND @PrtID2 IS NULL AND @PartDescription2 IS NOT NULL AND @PartCost2 IS NOT NULL
BEGIN
		Select @PartID2=newid()
		Insert PART (PARTGUID,PartDescription,PartCost,PartCharge,OrderedFrom,OrderNumber,Paid) Values(@PartID2,@PartDescription2,@PartCost2,@PartCharge2,@PartOrderedFrom2,@PartOrderNumber2,@Part2Paid)
		Insert PROBLEM_PART Values(@ProbID,@PartID2)
END
	Else If @@ROWCOUNT = 0 AND @PrtID2 IS NOT NULL AND @PartDescription2 IS NULL
BEGIN
		Delete From PROBLEM_PART Where PROBLEM_PROBLEMGUID = @ProbID AND PART_PARTGUID = @PrtID2
		Delete From PART Where PARTGUID = @PrtID2
		Select @PartID2=@PrtID2
END

	DECLARE @PartID3 uniqueidentifier
	If @PrtID3 IS NOT NULL AND @PartDescription3 IS NOT NULL AND @PartCost3 IS NOT NULL
BEGIN
		Update PART
		Set PartDescription = @PartDescription3, PartCost = @PartCost3, PartCharge = @PartCharge3, OrderedFrom = @PartOrderedFrom3, OrderNumber = @PartOrderNumber3, Paid = @Part3Paid
		Where PARTGUID = @PrtID3
		Select @PartID3=@PrtID3
END
	Else If @@ROWCOUNT = 0 AND @PrtID3 IS NULL AND @PartDescription3 IS NOT NULL AND @PartCost3 IS NOT NULL
BEGIN
		Select @PartID3=newid()
		Insert PART (PARTGUID,PartDescription,PartCost,PartCharge,OrderedFrom,OrderNumber,Paid) Values(@PartID3,@PartDescription3,@PartCost3,@PartCharge3,@PartOrderedFrom3,@PartOrderNumber3,@Part3Paid)
		Insert PROBLEM_PART Values(@ProbID,@PartID3)
END
	Else If @@ROWCOUNT = 0 AND @PrtID3 IS NOT NULL AND @PartDescription3 IS NULL
BEGIN
		Delete From PROBLEM_PART Where PROBLEM_PROBLEMGUID = @ProbID AND PART_PARTGUID = @PrtID3
		Delete From PART Where PARTGUID = @PrtID3
		Select @PartID3=@PrtID3
END

	DECLARE @PartID4 uniqueidentifier
	If @PrtID4 IS NOT NULL AND @PartDescription4 IS NOT NULL AND @PartCost4 IS NOT NULL
BEGIN
		Update PART
		Set PartDescription = @PartDescription4, PartCost = @PartCost4, PartCharge = @PartCharge4, OrderedFrom = @PartOrderedFrom4, OrderNumber = @PartOrderNumber4, Paid = @Part4Paid
		Where PARTGUID = @PrtID4
		Select @PartID4=@PrtID4
END
	Else If @@ROWCOUNT = 0 AND @PrtID4 IS NULL AND @PartDescription4 IS NOT NULL AND @PartCost4 IS NOT NULL
BEGIN
		Select @PartID4=newid()
		Insert PART (PARTGUID,PartDescription,PartCost,PartCharge,OrderedFrom,OrderNumber,Paid) Values(@PartID4,@PartDescription4,@PartCost4,@PartCharge4,@PartOrderedFrom4,@PartOrderNumber4,@Part4Paid)
		Insert PROBLEM_PART Values(@ProbID,@PartID4)
END
	Else If @@ROWCOUNT = 0 AND @PrtID4 IS NOT NULL AND @PartDescription4 IS NULL
BEGIN
		Delete From PROBLEM_PART Where PROBLEM_PROBLEMGUID = @ProbID AND PART_PARTGUID = @PrtID4
		Delete From PART Where PARTGUID = @PrtID4
		Select @PartID4=@PrtID4
END
	
	
	--Inserts task results and creates necessary guids
	DECLARE @TaskSequence decimal(2)
	Select @TaskSequence=1
	
	DECLARE @TaskValueNull decimal(10)
	Select @TaskValueNull=NULL
	
	DECLARE @TaskResultID1 uniqueidentifier
	Select @TaskResultID1=newid()
	Insert TASK_RESULT (TASK_RESULTGUID,Sequence,TaskValueNumber,TaskValueBoolean,EMPLOYEE_ID)
	Values(@TaskResultID1,@TaskSequence,@TaskValueNull,@TaskValueBoolean1,@TaskEMPLOYEE_ID1)

	DECLARE @TaskResultID2 uniqueidentifier
	Select @TaskResultID2=newid()
	Insert TASK_RESULT (TASK_RESULTGUID,Sequence,TaskValueNumber,TaskValueBoolean,EMPLOYEE_ID)
	Values(@TaskResultID2,@TaskSequence,@TaskValueNull,@TaskValueBoolean2,@TaskEMPLOYEE_ID2)

	DECLARE @TaskResultID3 uniqueidentifier
	Select @TaskResultID3=newid()
	Insert TASK_RESULT (TASK_RESULTGUID,Sequence,TaskValueNumber,TaskValueBoolean,EMPLOYEE_ID)
	Values(@TaskResultID3,@TaskSequence,@TaskValueNull,@TaskValueBoolean3,@TaskEMPLOYEE_ID3)

	DECLARE @TaskResultID4 uniqueidentifier
	Select @TaskResultID4=newid()
	Insert TASK_RESULT (TASK_RESULTGUID,Sequence,TaskValueNumber,TaskValueBoolean,EMPLOYEE_ID)
	Values(@TaskResultID4,@TaskSequence,@TaskValueNumber4,@TaskValueBoolean4,@TaskEMPLOYEE_ID4)

	DECLARE @TaskResultID5 uniqueidentifier
	Select @TaskResultID5=newid()
	Insert TASK_RESULT (TASK_RESULTGUID,Sequence,TaskValueNumber,TaskValueBoolean,EMPLOYEE_ID)
	Values(@TaskResultID5,@TaskSequence,@TaskValueNumber5,@TaskValueBoolean5,@TaskEMPLOYEE_ID5)

	DECLARE @TaskResultID6 uniqueidentifier
	Select @TaskResultID6=newid()
	Insert TASK_RESULT (TASK_RESULTGUID,Sequence,TaskValueNumber,TaskValueBoolean,EMPLOYEE_ID)
	Values(@TaskResultID6,@TaskSequence,@TaskValueNull,@TaskValueBoolean6,@TaskEMPLOYEE_ID6)

	DECLARE @TaskResultID7 uniqueidentifier
	Select @TaskResultID7=newid()
	Insert TASK_RESULT (TASK_RESULTGUID,Sequence,TaskValueNumber,TaskValueBoolean,EMPLOYEE_ID)
	Values(@TaskResultID7,@TaskSequence,@TaskValueNumber7,@TaskValueBoolean7,@TaskEMPLOYEE_ID7)

	DECLARE @TaskResultID8 uniqueidentifier
	Select @TaskResultID8=newid()
	Insert TASK_RESULT (TASK_RESULTGUID,Sequence,TaskValueNumber,TaskValueBoolean,EMPLOYEE_ID)
	Values(@TaskResultID8,@TaskSequence,@TaskValueNumber8,@TaskValueBoolean8,@TaskEMPLOYEE_ID8)

	DECLARE @TaskResultID9 uniqueidentifier
	Select @TaskResultID9=newid()
	Insert TASK_RESULT (TASK_RESULTGUID,Sequence,TaskValueNumber,TaskValueBoolean,EMPLOYEE_ID)
	Values(@TaskResultID9,@TaskSequence,@TaskValueNumber9,@TaskValueBoolean9,@TaskEMPLOYEE_ID9)

	DECLARE @TaskResultID10 uniqueidentifier
	Select @TaskResultID10=newid()
	Insert TASK_RESULT (TASK_RESULTGUID,Sequence,TaskValueNumber,TaskValueBoolean,EMPLOYEE_ID)
	Values(@TaskResultID10,@TaskSequence,@TaskValueNumber10,@TaskValueBoolean10,@TaskEMPLOYEE_ID10)

	DECLARE @TaskResultID11 uniqueidentifier
	Select @TaskResultID11=newid()
	Insert TASK_RESULT (TASK_RESULTGUID,Sequence,TaskValueNumber,TaskValueBoolean,EMPLOYEE_ID)
	Values(@TaskResultID11,@TaskSequence,@TaskValueNumber11,@TaskValueBoolean11,@TaskEMPLOYEE_ID11)

	DECLARE @TaskResultID12 uniqueidentifier
	Select @TaskResultID12=newid()
	Insert TASK_RESULT (TASK_RESULTGUID,Sequence,TaskValueNumber,TaskValueBoolean,EMPLOYEE_ID)
	Values(@TaskResultID12,@TaskSequence,@TaskValueNumber12,@TaskValueBoolean12,@TaskEMPLOYEE_ID12)

	DECLARE @TaskResultID13 uniqueidentifier
	Select @TaskResultID13=newid()
	Insert TASK_RESULT (TASK_RESULTGUID,Sequence,TaskValueNumber,TaskValueBoolean,EMPLOYEE_ID)
	Values(@TaskResultID13,@TaskSequence,@TaskValueNumber13,@TaskValueBoolean13,@TaskEMPLOYEE_ID13)

	DECLARE @TaskResultID14 uniqueidentifier
	Select @TaskResultID14=newid()
	Insert TASK_RESULT (TASK_RESULTGUID,Sequence,TaskValueNumber,TaskValueBoolean,EMPLOYEE_ID)
	Values(@TaskResultID14,@TaskSequence,@TaskValueNull,@TaskValueBoolean14,@TaskEMPLOYEE_ID14)
	
	DECLARE @TaskResultID15 uniqueidentifier
	Select @TaskResultID15=newid()
	Insert TASK_RESULT (TASK_RESULTGUID,Sequence,TaskValueNumber,TaskValueBoolean,EMPLOYEE_ID)
	Values(@TaskResultID15,@TaskSequence,@TaskValueNumber15,@TaskValueBoolean15,@TaskEMPLOYEE_ID15)

	DECLARE @TaskResultID16 uniqueidentifier
	Select @TaskResultID16=newid()
	Insert TASK_RESULT (TASK_RESULTGUID,Sequence,TaskValueNumber,TaskValueBoolean,EMPLOYEE_ID)
	Values(@TaskResultID16,@TaskSequence,@TaskValueNull,@TaskValueBoolean16,@TaskEMPLOYEE_ID16)

	DECLARE @TaskResultID17 uniqueidentifier
	Select @TaskResultID17=newid()
	Insert TASK_RESULT (TASK_RESULTGUID,Sequence,TaskValueNumber,TaskValueBoolean,EMPLOYEE_ID)
	Values(@TaskResultID17,@TaskSequence,@TaskValueNumber17,@TaskValueBoolean17,@TaskEMPLOYEE_ID17)

	DECLARE @TaskResultID18 uniqueidentifier
	Select @TaskResultID18=newid()
	Insert TASK_RESULT (TASK_RESULTGUID,Sequence,TaskValueNumber,TaskValueBoolean,EMPLOYEE_ID)
	Values(@TaskResultID18,@TaskSequence,@TaskValueNull,@TaskValueBoolean18,@TaskEMPLOYEE_ID18)

	DECLARE @TaskResultID19 uniqueidentifier
	Select @TaskResultID19=newid()
	Insert TASK_RESULT (TASK_RESULTGUID,Sequence,TaskValueNumber,TaskValueBoolean,EMPLOYEE_ID)
	Values(@TaskResultID19,@TaskSequence,@TaskValueNull,@TaskValueBoolean19,@TaskEMPLOYEE_ID19)

	DECLARE @TaskResultID20 uniqueidentifier
	Select @TaskResultID20=newid()
	Insert TASK_RESULT (TASK_RESULTGUID,Sequence,TaskValueNumber,TaskValueBoolean,EMPLOYEE_ID)
	Values(@TaskResultID20,@TaskSequence,@TaskValueNull,@TaskValueBoolean20,@TaskEMPLOYEE_ID20)

	DECLARE @TaskResultID21 uniqueidentifier
	Select @TaskResultID21=newid()
	Insert TASK_RESULT (TASK_RESULTGUID,Sequence,TaskValueNumber,TaskValueBoolean,EMPLOYEE_ID)
	Values(@TaskResultID21,@TaskSequence,@TaskValueNull,@TaskValueBoolean21,@TaskEMPLOYEE_ID21)

	DECLARE @TaskResultID22 uniqueidentifier
	Select @TaskResultID22=newid()
	Insert TASK_RESULT (TASK_RESULTGUID,Sequence,TaskValueNumber,TaskValueBoolean,EMPLOYEE_ID)
	Values(@TaskResultID22,@TaskSequence,@TaskValueNull,@TaskValueBoolean22,@TaskEMPLOYEE_ID22)

	DECLARE @TaskResultID23 uniqueidentifier
	Select @TaskResultID23=newid()
	Insert TASK_RESULT (TASK_RESULTGUID,Sequence,TaskValueNumber,TaskValueBoolean,EMPLOYEE_ID)
	Values(@TaskResultID23,@TaskSequence,@TaskValueNull,@TaskValueBoolean23,@TaskEMPLOYEE_ID23)

	DECLARE @TaskResultID24 uniqueidentifier
	Select @TaskResultID24=newid()
	Insert TASK_RESULT (TASK_RESULTGUID,Sequence,TaskValueNumber,TaskValueBoolean,EMPLOYEE_ID)
	Values(@TaskResultID24,@TaskSequence,@TaskValueNull,@TaskValueBoolean24,@TaskEMPLOYEE_ID24)
	
	DECLARE @TaskResultID25 uniqueidentifier
	Select @TaskResultID25=newid()
	Insert TASK_RESULT (TASK_RESULTGUID,Sequence,TaskValueNumber,TaskValueBoolean,EMPLOYEE_ID)
	Values(@TaskResultID25,@TaskSequence,@TaskValueNull,@TaskValueBoolean25,@TaskEMPLOYEE_ID25)
	
	DECLARE @TaskResultID26 uniqueidentifier
	Select @TaskResultID26=newid()
	Insert TASK_RESULT (TASK_RESULTGUID,Sequence,TaskValueNumber,TaskValueBoolean,EMPLOYEE_ID)
	Values(@TaskResultID26,@TaskSequence,@TaskValueNull,@TaskValueBoolean26,@TaskEMPLOYEE_ID26)
	
	DECLARE @TaskResultID27 uniqueidentifier
	Select @TaskResultID27=newid()
	Insert TASK_RESULT (TASK_RESULTGUID,Sequence,TaskValueNumber,TaskValueBoolean,EMPLOYEE_ID)
	Values(@TaskResultID27,@TaskSequence,@TaskValueNull,@TaskValueBoolean27,@TaskEMPLOYEE_ID27)
	
	
	--relates a given task to a problem and a result
	DECLARE @TaskID1 uniqueidentifier
	Select @TaskID1='8618A66D-F93E-4C6F-8177-B872D57875A2'
	Insert PROBLEM_TASK_TASK_RESULT (PROBLEM_PROBLEMGUID,TASK_TASKGUID,TASK_RESULT_TASK_RESULTGUID)
	Values(@ProbID,@TaskID1,@TaskResultID1)

	DECLARE @TaskID2 uniqueidentifier
	Select @TaskID2='44FB630F-365A-4F9A-B1C9-723D5C3D097F'
	Insert PROBLEM_TASK_TASK_RESULT (PROBLEM_PROBLEMGUID,TASK_TASKGUID,TASK_RESULT_TASK_RESULTGUID)
	Values(@ProbID,@TaskID2,@TaskResultID2)

	DECLARE @TaskID3 uniqueidentifier
	Select @TaskID3='142CABB1-8F72-4299-8C5E-19BE204B7B98'
	Insert PROBLEM_TASK_TASK_RESULT (PROBLEM_PROBLEMGUID,TASK_TASKGUID,TASK_RESULT_TASK_RESULTGUID)
	Values(@ProbID,@TaskID3,@TaskResultID3)

	DECLARE @TaskID4 uniqueidentifier
	Select @TaskID4='B14C0B6F-2979-437D-B813-B492E21D9DD9'
	Insert PROBLEM_TASK_TASK_RESULT (PROBLEM_PROBLEMGUID,TASK_TASKGUID,TASK_RESULT_TASK_RESULTGUID)
	Values(@ProbID,@TaskID4,@TaskResultID4)

	DECLARE @TaskID5 uniqueidentifier
	Select @TaskID5='B609B5BE-BF70-4B26-83DF-7F3E54E20CBD'
	Insert PROBLEM_TASK_TASK_RESULT (PROBLEM_PROBLEMGUID,TASK_TASKGUID,TASK_RESULT_TASK_RESULTGUID)
	Values(@ProbID,@TaskID5,@TaskResultID5)

	DECLARE @TaskID6 uniqueidentifier
	Select @TaskID6='7260F164-684B-40BC-A331-69F97D1F39D9'
	Insert PROBLEM_TASK_TASK_RESULT (PROBLEM_PROBLEMGUID,TASK_TASKGUID,TASK_RESULT_TASK_RESULTGUID)
	Values(@ProbID,@TaskID6,@TaskResultID6)

	DECLARE @TaskID7 uniqueidentifier
	Select @TaskID7='0F1FBCAA-0D46-4557-8D10-7D31E21B0642'
	Insert PROBLEM_TASK_TASK_RESULT (PROBLEM_PROBLEMGUID,TASK_TASKGUID,TASK_RESULT_TASK_RESULTGUID)
	Values(@ProbID,@TaskID7,@TaskResultID7)

	DECLARE @TaskID8 uniqueidentifier
	Select @TaskID8='3E2ADF40-70E4-4CCF-A86B-3DE11E37D49B'
	Insert PROBLEM_TASK_TASK_RESULT (PROBLEM_PROBLEMGUID,TASK_TASKGUID,TASK_RESULT_TASK_RESULTGUID)
	Values(@ProbID,@TaskID8,@TaskResultID8)

	DECLARE @TaskID9 uniqueidentifier
	Select @TaskID9='2B21F4D4-7AF3-45C9-AC4D-9A3606AEC6DF'
	Insert PROBLEM_TASK_TASK_RESULT (PROBLEM_PROBLEMGUID,TASK_TASKGUID,TASK_RESULT_TASK_RESULTGUID)
	Values(@ProbID,@TaskID9,@TaskResultID9)

	DECLARE @TaskID10 uniqueidentifier
	Select @TaskID10='DEF30D61-9DDF-4735-8809-76400B201C6D'
	Insert PROBLEM_TASK_TASK_RESULT (PROBLEM_PROBLEMGUID,TASK_TASKGUID,TASK_RESULT_TASK_RESULTGUID)
	Values(@ProbID,@TaskID10,@TaskResultID10)

	DECLARE @TaskID11 uniqueidentifier
	Select @TaskID11='36E29FE5-6217-49EA-8F00-49DB6300EB8F'
	Insert PROBLEM_TASK_TASK_RESULT (PROBLEM_PROBLEMGUID,TASK_TASKGUID,TASK_RESULT_TASK_RESULTGUID)
	Values(@ProbID,@TaskID11,@TaskResultID11)

	DECLARE @TaskID12 uniqueidentifier
	Select @TaskID12='D5C19173-F474-4E55-8D48-22E532D55CF6'
	Insert PROBLEM_TASK_TASK_RESULT (PROBLEM_PROBLEMGUID,TASK_TASKGUID,TASK_RESULT_TASK_RESULTGUID)
	Values(@ProbID,@TaskID12,@TaskResultID12)

	DECLARE @TaskID13 uniqueidentifier
	Select @TaskID13='03932B67-DAB1-4D07-A49F-4C63352002AD'
	Insert PROBLEM_TASK_TASK_RESULT (PROBLEM_PROBLEMGUID,TASK_TASKGUID,TASK_RESULT_TASK_RESULTGUID)
	Values(@ProbID,@TaskID13,@TaskResultID13)

	DECLARE @TaskID14 uniqueidentifier
	Select @TaskID14='749BB3CE-6A15-45DC-97F0-57EC6A1E925E'
	Insert PROBLEM_TASK_TASK_RESULT (PROBLEM_PROBLEMGUID,TASK_TASKGUID,TASK_RESULT_TASK_RESULTGUID)
	Values(@ProbID,@TaskID14,@TaskResultID14)

	DECLARE @TaskID15 uniqueidentifier
	Select @TaskID15='F8A9A837-49E1-4C96-87F3-795F74503FDC'
	Insert PROBLEM_TASK_TASK_RESULT (PROBLEM_PROBLEMGUID,TASK_TASKGUID,TASK_RESULT_TASK_RESULTGUID)
	Values(@ProbID,@TaskID15,@TaskResultID15)

	DECLARE @TaskID16 uniqueidentifier
	Select @TaskID16='291B77EB-08E9-4FCB-80CC-3B869DADBE8C'
	Insert PROBLEM_TASK_TASK_RESULT (PROBLEM_PROBLEMGUID,TASK_TASKGUID,TASK_RESULT_TASK_RESULTGUID)
	Values(@ProbID,@TaskID16,@TaskResultID16)

	DECLARE @TaskID17 uniqueidentifier
	Select @TaskID17='AB19B922-3E7A-4AD3-9B02-46D180C5CDAF'
	Insert PROBLEM_TASK_TASK_RESULT (PROBLEM_PROBLEMGUID,TASK_TASKGUID,TASK_RESULT_TASK_RESULTGUID)
	Values(@ProbID,@TaskID17,@TaskResultID17)

	DECLARE @TaskID18 uniqueidentifier
	Select @TaskID18='0A901879-5BBE-493A-9259-4F82BF202E3A'
	Insert PROBLEM_TASK_TASK_RESULT (PROBLEM_PROBLEMGUID,TASK_TASKGUID,TASK_RESULT_TASK_RESULTGUID)
	Values(@ProbID,@TaskID18,@TaskResultID18)

	DECLARE @TaskID19 uniqueidentifier
	Select @TaskID19='913084C0-870F-422B-AD8C-A4720F3C0ECA'
	Insert PROBLEM_TASK_TASK_RESULT (PROBLEM_PROBLEMGUID,TASK_TASKGUID,TASK_RESULT_TASK_RESULTGUID)
	Values(@ProbID,@TaskID19,@TaskResultID19)

	DECLARE @TaskID20 uniqueidentifier
	Select @TaskID20='6476EEDE-29BB-4EB2-BF17-899DC82C5245'
	Insert PROBLEM_TASK_TASK_RESULT (PROBLEM_PROBLEMGUID,TASK_TASKGUID,TASK_RESULT_TASK_RESULTGUID)
	Values(@ProbID,@TaskID20,@TaskResultID20)

	DECLARE @TaskID21 uniqueidentifier
	Select @TaskID21='4559E0CA-3E9F-40CD-8A8F-49DC4ED51915'
	Insert PROBLEM_TASK_TASK_RESULT (PROBLEM_PROBLEMGUID,TASK_TASKGUID,TASK_RESULT_TASK_RESULTGUID)
	Values(@ProbID,@TaskID21,@TaskResultID21)

	DECLARE @TaskID22 uniqueidentifier
	Select @TaskID22='E984B67D-697F-4527-8AB1-C165DD195F59'
	Insert PROBLEM_TASK_TASK_RESULT (PROBLEM_PROBLEMGUID,TASK_TASKGUID,TASK_RESULT_TASK_RESULTGUID)
	Values(@ProbID,@TaskID22,@TaskResultID22)

	DECLARE @TaskID23 uniqueidentifier
	Select @TaskID23='5F541F0D-8B12-4E25-95FC-F51CD58F25C0'
	Insert PROBLEM_TASK_TASK_RESULT (PROBLEM_PROBLEMGUID,TASK_TASKGUID,TASK_RESULT_TASK_RESULTGUID)
	Values(@ProbID,@TaskID23,@TaskResultID23)

	DECLARE @TaskID24 uniqueidentifier
	Select @TaskID24='CDE1F58E-85D6-41CD-81AE-56690242A4C7'
	Insert PROBLEM_TASK_TASK_RESULT (PROBLEM_PROBLEMGUID,TASK_TASKGUID,TASK_RESULT_TASK_RESULTGUID)
	Values(@ProbID,@TaskID24,@TaskResultID24)

	DECLARE @TaskID25 uniqueidentifier
	Select @TaskID25='40A9A16E-2B26-400E-8E81-EC46C79A6F65'
	Insert PROBLEM_TASK_TASK_RESULT (PROBLEM_PROBLEMGUID,TASK_TASKGUID,TASK_RESULT_TASK_RESULTGUID)
	Values(@ProbID,@TaskID25,@TaskResultID25)

	DECLARE @TaskID26 uniqueidentifier
	Select @TaskID26='4D7243C4-233D-4FF2-8220-A54AA0DCB198'
	Insert PROBLEM_TASK_TASK_RESULT (PROBLEM_PROBLEMGUID,TASK_TASKGUID,TASK_RESULT_TASK_RESULTGUID)
	Values(@ProbID,@TaskID26,@TaskResultID26)

	DECLARE @TaskID27 uniqueidentifier
	Select @TaskID27='12E93E96-FFFE-45B4-94F3-9FC3ED7C4627'
	Insert PROBLEM_TASK_TASK_RESULT (PROBLEM_PROBLEMGUID,TASK_TASKGUID,TASK_RESULT_TASK_RESULTGUID)
	Values(@ProbID,@TaskID27,@TaskResultID27)
	

	--Inserts service charges
	If @ServiceID1 IS NOT NULL AND @ChargeAmount1 IS NOT NULL
		Insert PROBLEM_SERVICE_CHARGE (PROBLEM_PROBLEMGUID,SERVICE_SERVICEGUID,[Override],ChargeAmount,Paid) 
		Values(@ProbID,@ServiceID1,@ChargeOverride1,@ChargeAmount1,@Service1Paid)

	If @ServiceID2 IS NOT NULL AND @ChargeAmount2 IS NOT NULL
		Insert PROBLEM_SERVICE_CHARGE (PROBLEM_PROBLEMGUID,SERVICE_SERVICEGUID,[Override],ChargeAmount,Paid)
		Values(@ProbID,@ServiceID2,@ChargeOverride2,@ChargeAmount2,@Service2Paid)

	If @ServiceID3 IS NOT NULL AND @ChargeAmount3 IS NOT NULL
		Insert PROBLEM_SERVICE_CHARGE (PROBLEM_PROBLEMGUID,SERVICE_SERVICEGUID,[Override],ChargeAmount,Paid)
		Values(@ProbID,@ServiceID3,@ChargeOverride3,@ChargeAmount3,@Service3Paid)

	If @ServiceID4 IS NOT NULL AND @ChargeAmount4 IS NOT NULL
		Insert PROBLEM_SERVICE_CHARGE (PROBLEM_PROBLEMGUID,SERVICE_SERVICEGUID,[Override],ChargeAmount,Paid)
		Values(@ProbID,@ServiceID4,@ChargeOverride4,@ChargeAmount4,@Service4Paid)

	If @ServiceID5 IS NOT NULL AND @ChargeAmount5 IS NOT NULL
		Insert PROBLEM_SERVICE_CHARGE (PROBLEM_PROBLEMGUID,SERVICE_SERVICEGUID,[Override],ChargeAmount,Paid)
		Values(@ProbID,@ServiceID5,@ChargeOverride5,@ChargeAmount5,@Service5Paid)
		
END
GO

The reason I believe the issue is the stored proc and not the code you originally provided is because all the code you provided shows is opening the connection, utilizing the stored proc to insert data and closing the connection.

If all it's doing is calling to the stored proc and nothing more then, logically, the stored proc is the source of the overwrite.

Maybe someone looking over the HUGE stored proc you provided above will be able to find the issue, or, maybe I was wrong... either way, it doesn't hurt to have as much info as possible to work with when attempting to find the source of an issue :)

It is kinda big, huh?

Found another interesting quirk related to this issue...
When two users run the page that opens the connection and executes the stored procedure, another page is immediately called that retrieves that data and presents it in a more legible format. That page is ALWAYS correct. Yet, when you go searching for the data that was just inserted, it may have been overwritten.

>>When two users run the page that opens the connection and executes the stored procedure...That page is ALWAYS correct.

Generally this can be attributed to the fact that you are utilizing 'local' variable sets on this page as opposed to the information present in the database. Each user gets their own 'session' on the server which contains all the local variables from their input and, unless you're drawing your results from the DB on the generation of the 'result' page you're presenting, all they're getting back is the information they submitted regurgitated in the 'formatted' view.

It is querying the database directly.
The first page, after inserting the data through the stored proc, retrieves the necessary id column and then passes that as a query string to the result page, which then runs a query and retrieves the data.

Sounds impossible, I know, but I can't find a solution.

Ok... well....

Here's my theory (and no, I didn't make it all the way through your Stored Proc, sorry)...

  1. User 1 enters their input and submits
  2. User 1 receives confirmation of their input from the DB
  3. User 2 enters their input and submits
  4. User 2 receives confirmation of their input from the DB
  5. Both users receive correct information as, while they seem simultaneous in their entry they're actually still 'in order' based on the fractions of fractions of seconds it takes for the process to complete
  6. Entry 2 is assigned some sort of transaction key that is identical to Entry 1's transaction key due to a mis-code in the stored proc (stored proc may be giving both a transaction # of, say, 12) generally caused by the proc checking for existing key prior to processing and applying transaction key after processing, this can be avoided by having transaction keys auto-generated by the server instead of code
  7. Entry 1 is overwritten due to Entry 2 having identical transaction key

This is just my 'theory' on what's going on however. As I said, I've been kind of busy lately and haven't gotten through all of your code to confirm it.

No problem. I appreciate all the help you have given, and that gives me a good place to start looking.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.