Insert stored procedure for a Form

  • I have a question regarding inserting data from a form. The form on the web site contains the actual names of the territories, regions, divisions, etc. However, we also have ID numbers created for each of these. So, what I want to happen is this: Once the fields are filled in with their respective names, I want the associated numbers to be stored in the table. I have created this stored procedure, but when the data is entered into the fields and the submit button is clicked, the new data is not recognized or entered into the table. I do not receive an error message, though. I am brought to the datagrid, but like i said, the data that had just been entered into the field does not appear. Here is the code. I would greatly appreciate any help or suggestions.

     

    CREATE PROCEDURE [InsertAccountTransfer]

    @AccountNumber nvarchar(10) ,

    @FromTerritory nvarchar(50) ,

    @FromTM nvarchar(50),

    @FromRegion nvarchar(50),

    @FromDivision nvarchar(50),

    @ToTerritory nvarchar(50),

    @ToTM nvarchar(50),

    @ToRegion nvarchar(50),

    @ToDivision nvarchar(50)

    AS

    Insert INTO AccountTransfersTest

    (AccountNumber, FromTerritory, FromTM, FromRegion, FromDivision, ToTerritory, ToTM, ToRegion, ToDivision)

    select @AccountNumber, accounttransfers.FromTMID, accounttransfers.ToTMID, territories.territoryID, territories.territoryID, regions.regionID, regions.regionID, divisions.DivisionID, divisions.DivisionID

    from territories, regions, divisions, accounttransfers

    where territories.territory = @FromTerritory AND accounttransfers.FromTM = @FromTM AND regions.region = @FromRegion AND divisions.division = @FromDivision AND territories.territory = @ToTerritory AND accounttransfers.ToTM = @ToTM AND regions.region = @ToRegion AND divisions.division = @ToDivision

    GO

  • HI,

    With a problem like this I have found that the best way to debug this type of problerm is ...

    Do not execute the procedure from asp. Response write your entire execution statment with the variables populated.

    Copy the statment and past "as is" into Query Analyser and execute. This will give you a very clear Front-end/Back end picture of what the problem is...


    Andy.

  • also you can insert these values into a temp talble (like AccountTransfersTestTEMP .. which you made like the original AccountTransfersTest but with auto number )

    and then call a stored procedure that copy the data from your temp table to your original table

    I hope this help u


    Alamir Mohamed
    Alamir_mohamed@yahoo.com

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply