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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:29:05+00:00 2026-06-01T10:29:05+00:00

I know it might be a duplicate question but it is really making me

  • 0

I know it might be a duplicate question but it is really making me frustrated now. I have to insert/update shipper information and I wrote a stored procedure like this:

IF EXISTS (SELECT * FROM sysobjects WHERE name='usp_Nucleus_LSS_AddShipperInfo' AND type='P')
    DROP PROCEDURE usp_Nucleus_LSS_AddShipperInfo 
GO 

CREATE PROCEDURE dbo.usp_Nucleus_LSS_AddShipperInfo 
(
    @ShipperCode varchar(500),
    @ShipperName varchar(500),
    @CustomsClearance decimal,
    @MinCommissionAmount decimal,
    @CommissionPercent decimal,
    @TruckingAmount decimal,
    @ContractNo varchar(50),
    @ConsigneeName varchar(500),
    @SalesPerson varchar(500),
    @Email varchar(500),
    @ContactNo varchar(500),
    @ShipperPriority varchar(50),
    @EntryBy varchar(50),
    @EntryDate datetime,
    @UpdatedBy varchar(50),
    @UpdateDate datetime
)
AS 
DECLARE
    @NewShipperID bigint,
    @OldShipperID bigint 
BEGIN 
    SELECT @OldShipperID = (SELECT ISNULL(ShipperID, 0) AS ShipperID FROM LSS_t_ShipperInfo WHERE ShipperCode = @ShipperCode)
    SELECT @NewShipperID = (SELECT ISNULL(MAX(ShipperID),0) AS ShipperID FROM LSS_t_ShipperInfo)
    IF (@OldShipperID > 0)
        BEGIN 
            UPDATE LSS_t_ShipperInfo SET ShipperName=@ShipperName, CustomsClearance=@CustomsClearance, 
            MinCommissionAmount=@MinCommissionAmount, CommissionPercent=@CommissionPercent, TruckingAmount=@TruckingAmount, 
            ContractNo=@ContractNo, ConsigneeName=@ConsigneeName, SalesPerson=@SalesPerson, Email=@Email, ContactNo=@ContactNo, 
            ShipperPriority=@ShipperPriority, UpdatedBy=@UpdatedBy, UpdateDate=@UpdateDate 
            WHERE ShipperID = @OldShipperID 
        END 
    ELSE
        BEGIN
            INSERT INTO LSS_t_ShipperInfo (ShipperID, ShipperCode, ShipperName, CustomsClearance, MinCommissionAmount, 
            CommissionPercent, TruckingAmount, ContractNo, ConsigneeName, SalesPerson, Email, ContactNo, ShipperPriority, EntryBy, 
            EntryDate, UpdatedBy, UpdateDate) VALUES (@NewShipperID+1, @ShipperCode, @ShipperName, @CustomsClearance, @MinCommissionAmount, 
            @CommissionPercent, @TruckingAmount, @ContractNo, @ConsigneeName, @SalesPerson, @Email, @ContactNo, @ShipperPriority, @EntryBy, 
            @EntryDate, @UpdatedBy, @UpdateDate)
        END
END 

GO 

I executed this from my app using a single row and it worked. but next time when i again run it using two rows, it neither inserts nor updates records. I don’t understand what is the problem here. I run each query separately and they work fine. Here is my VB.Net code:

oDBCmd.Connection = oDBCon
                oDBCmd.CommandText = "usp_Nucleus_LSS_AddShipperInfo"
                oDBCmd.CommandType = CommandType.StoredProcedure
                oDBCmd.CommandTimeout = 0
                nResult = -1

                oDBCmd.Parameters.Add("@ShipperCode", OleDbType.VarChar).Value = DGMAIN.Rows(i).Cells("DGMAIN_SHIPPER_CODE").Value.ToString()
                oDBCmd.Parameters.Add("@ShipperName", OleDbType.VarChar).Value = DGMAIN.Rows(i).Cells("DGMAIN_SHIPPER_NAME").Value.ToString()
                oDBCmd.Parameters.Add("@CustomsClearance", OleDbType.Decimal).Value = DGMAIN.Rows(i).Cells("DGMAIN_CUSTOMS_CLEARANCE").Value.ToString()
                oDBCmd.Parameters.Add("@MinCommissionAmount", OleDbType.Decimal).Value = DGMAIN.Rows(i).Cells("DGMAIN_MIN_COMMISSION_AMOUNT").Value.ToString()
                oDBCmd.Parameters.Add("@CommissionPercent", OleDbType.Decimal).Value = DGMAIN.Rows(i).Cells("DGMAIN_COMMISSION_PERCENT").Value.ToString()
                oDBCmd.Parameters.Add("@TruckingAmount", OleDbType.Decimal).Value = DGMAIN.Rows(i).Cells("DGMAIN_TRUCKING_AMOUNT").Value.ToString()
                oDBCmd.Parameters.Add("@ContractNo", OleDbType.VarChar).Value = DGMAIN.Rows(i).Cells("DGMAIN_CONTRACT_NO").Value.ToString()
                oDBCmd.Parameters.Add("@ConsigneeName", OleDbType.VarChar).Value = DGMAIN.Rows(i).Cells("DGMAIN_CONSIGNEE_NAME").Value.ToString()
                oDBCmd.Parameters.Add("@SalesPerson", OleDbType.VarChar).Value = DGMAIN.Rows(i).Cells("DGMAIN_SALES_PERSON").Value.ToString()
                oDBCmd.Parameters.Add("@Email", OleDbType.VarChar).Value = DGMAIN.Rows(i).Cells("DGMAIN_EMAIL").Value.ToString()
                oDBCmd.Parameters.Add("@ContactNo", OleDbType.VarChar).Value = DGMAIN.Rows(i).Cells("DGMAIN_CONTACT_NO").Value.ToString()
                oDBCmd.Parameters.Add("@ShipperPriority", OleDbType.VarChar).Value = DGMAIN.Rows(i).Cells("DGMAIN_SHIPPER_PRIORITY").Value.ToString()
                oDBCmd.Parameters.Add("@EntryBy", OleDbType.VarChar).Value = System.Environment.UserName.ToString().ToUpper()
                oDBCmd.Parameters.Add("@EntryDate", OleDbType.Date).Value = System.DateTime.Now().ToString()
                oDBCmd.Parameters.Add("@UpdatedBy", OleDbType.VarChar).Value = System.Environment.UserName.ToString().ToUpper()
                oDBCmd.Parameters.Add("@UpdateDate", OleDbType.Date).Value = System.DateTime.Now().ToString()

                nResult = oDBCmd.ExecuteNonQuery()

I am using VB.Net 2.0 and SQL Server Enterprise edition.

Thanks in advance.

  • 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-06-01T10:29:06+00:00Added an answer on June 1, 2026 at 10:29 am

    I have look at in your stored procedure , its looking fine .

    I think you have problem with your vb.net code. I doubt you are missing the for loop for executing multiple rows of datatable.

    Try this code here:

        For i As Integer = 0 To DGMAIN.Rows.Count - 1
            oDBCmd = New SqlCommand
            oDBCmd.Connection = oDBCon
            oDBCmd.CommandText = "usp_Nucleus_LSS_AddShipperInfo"
            oDBCmd.CommandType = CommandType.StoredProcedure
            oDBCmd.CommandTimeout = 0
            nResult = -1
    
            oDBCmd.Parameters.Add("@ShipperCode", OleDbType.VarChar).Value = DGMAIN.Rows(i)("DGMAIN_SHIPPER_CODE").Value.ToString()
            oDBCmd.Parameters.Add("@ShipperName", OleDbType.VarChar).Value = DGMAIN.Rows(i)("DGMAIN_SHIPPER_NAME").Value.ToString()
            oDBCmd.Parameters.Add("@CustomsClearance", OleDbType.Decimal).Value = DGMAIN.Rows(i)("DGMAIN_CUSTOMS_CLEARANCE").Value.ToString()
            oDBCmd.Parameters.Add("@MinCommissionAmount", OleDbType.Decimal).Value = DGMAIN.Rows(i)("DGMAIN_MIN_COMMISSION_AMOUNT").Value.ToString()
            oDBCmd.Parameters.Add("@CommissionPercent", OleDbType.Decimal).Value = DGMAIN.Rows(i)("DGMAIN_COMMISSION_PERCENT").Value.ToString()
            oDBCmd.Parameters.Add("@TruckingAmount", OleDbType.Decimal).Value = DGMAIN.Rows(i)("DGMAIN_TRUCKING_AMOUNT").Value.ToString()
            oDBCmd.Parameters.Add("@ContractNo", OleDbType.VarChar).Value = DGMAIN.Rows(i)("DGMAIN_CONTRACT_NO").Value.ToString()
            oDBCmd.Parameters.Add("@ConsigneeName", OleDbType.VarChar).Value = DGMAIN.Rows(i)("DGMAIN_CONSIGNEE_NAME").Value.ToString()
            oDBCmd.Parameters.Add("@SalesPerson", OleDbType.VarChar).Value = DGMAIN.Rows(i)("DGMAIN_SALES_PERSON").Value.ToString()
            oDBCmd.Parameters.Add("@Email", OleDbType.VarChar).Value = DGMAIN.Rows(i)("DGMAIN_EMAIL").Value.ToString()
            oDBCmd.Parameters.Add("@ContactNo", OleDbType.VarChar).Value = DGMAIN.Rows(i)("DGMAIN_CONTACT_NO").Value.ToString()
            oDBCmd.Parameters.Add("@ShipperPriority", OleDbType.VarChar).Value = DGMAIN.Rows(i)("DGMAIN_SHIPPER_PRIORITY").Value.ToString()
            oDBCmd.Parameters.Add("@EntryBy", OleDbType.VarChar).Value = System.Environment.UserName.ToString().ToUpper()
            oDBCmd.Parameters.Add("@EntryDate", OleDbType.Date).Value = System.DateTime.Now().ToString()
            oDBCmd.Parameters.Add("@UpdatedBy", OleDbType.VarChar).Value = System.Environment.UserName.ToString().ToUpper()
            oDBCmd.Parameters.Add("@UpdateDate", OleDbType.Date).Value = System.DateTime.Now().ToString()
    
            nResult = oDBCmd.ExecuteNonQuery()
    
        Next
    

    Hope this will helpful to you

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

Sidebar

Related Questions

I know this might seem a controversial question but it really is not meant
I know that this might be a duplicate of this question but that was
I know this might be a long shot, but here it goes. I have
This might be a duplicate question but as you can see they didn't get
This is almost a duplicate question, but I really didn't understand the answer given
Know this might be rather basic, but I been trying to figure out how
I know this might be a no-brainer, but please read on. I also know
I know this might be a bit awkward but I am trying to modify
I know this might be very easy to some,, I have a simple string
As you might know, it's now possible to trace Erlang functions by using the

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.