Results 1 to 3 of 3

Thread: Help with SP

  1. #1
    Join Date
    Dec 2003
    Posts
    11

    Unanswered: Help with SP

    I have a webform that I need to insert data into a db. I would like to have a stored procedure handle the insert for me.

    Here are the data fields from the form:

    Code:
    <td><asp:textbox id="f_name" runat="server"></asp:textbox></td>
    <td><asp:textbox id="l_name" runat="server"></asp:textbox></td>
    <td><asp:textbox id="emp_num" runat="server"></asp:textbox></td>
    <td><asp:textbox id="email" runat="server"></asp:textbox></td>
    <td><asp:dropdownlist id=dd1 runat="server" DataMember="Line_Item" DataSource="<%# dsLineItem1 %>" DataTextField="LI_ID" DataValueField="ID"></asp:dropdownlist></td>
    <td><asp:dropdownlist id=dd2 runat="server" DataMember="Component" DataSource="<%# dsComponent1 %>" DataTextField="Component" DataValueField="ID"></asp:dropdownlist></td>
    <td><asp:dropdownlist id=dd3 runat="server" DataMember="Activity" DataSource="<%# dsActivity1 %>" DataTextField="Abbrev" DataValueField="ID"></asp:dropdownlist></td>
    Needed Solution:
    I need to create a stored procedure that will insert the data from the above fields into the following database:

    ProfileDB
    Table columns:
    id
    f_name
    l_name
    emp_num
    email
    line_item
    component
    activity

    I am sure that there are some rules for this I am unaware of (such as field names must match table column names etc.).

    Thank you for your help.

    BTW,

    My version of SQL is 2000.

    Thank you again.

    Sincerely,

    Tim

  2. #2
    Join Date
    Dec 2003
    Posts
    11

    SP1

    I have constucted a stored procedure that is at the least error free:
    If you have any comments or suggestions regarding this sp I would greatly appreciate your input since I am new to SQL.

    Code:
    
    
    CREATE PROCEDURE dbo.InsertProfile
    (
    @F_Name [varchar] (100),
    @L_Name [varchar] (100),
    @Emp_Num [numeric] (9),
    @Email [varchar] (250),
    @Line_Item [varchar] (250),
    @Component [varchar] (250),
    @Activity [varchar] (250)
    )
    
     AS
    
    Insert into [dbo.InsertProfile]
    (
    [F_Name],
    [L_Name],
    [Emp_Num],
    [Email],
    [Line_Item],
    [Component],
    [Activity]
    )
    
    Values
    
    (@F_Name, @L_Name, @Emp_Num, @Email, @Line_Item, @Component, @Activity)
    
    GO
    
    Thank you.

  3. #3
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    OK

    You might want to check for errors


    DECLARE @Error, @Rowcount

    ...sql statement

    SELECT @Error = @@ERROR, @RowCount = @@Rowcount

    Then interogate thos values...if @Error is other than 0, then you have a problem...

    And if @Rowcount doesn't = 1 the that's a problem as well (don't know how that would ever happen, but it's a check)
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •