Stored procedure wont insert Fields, RadioButtonLists and CheckBox

Discussion in 'ASP .Net' started by JB, Feb 25, 2010.

  1. JB

    JB Guest

    Hello Community

    I have a CheckBox and a RadioButtonList and fields on an aspx web page form.
    I pass the fields on the form to a method that creates the parameters and
    executes a stored procedure and the stored procedure is supposed to insert
    this information as a row into a table.

    For some reason the stored procedure executes but the row does not get
    inserted. I can’t see why the row doesn’t get inserted especially since I
    put BreakPoints in the code all along the way and I see the values just as
    they get passed into the stored procedure but maybe someone looking at this
    can see why the row doesn't get inserted or have an idea why a row doesn't
    insert. Note: there are more fields in this table than I am showing, these
    are just some of the fields that I am inserting into the table and that are
    in the table:

    The only thing I could think of is maybe I can’t insert the values I am
    trying to insert into the fields that are defined for the CheckBox and
    RadioButtonList:

    **** Initialize variable
    string strSerialNumber = "";
    string cbNoDispatch = " ";
    int cbCaller = 0;
    int rdoUsed = 0;
    DateTime CallDate = new DateTime();

    ****get values for variable
    strSerialNumber =.GetSerialNum(gval);

    if (chkNoDispatch.Checked)
    cbNoDispatch = "Y";
    else
    cbNoDispatch = "N";

    if (chkCaller.Checked)
    cbCaller = 0;
    else
    cbCaller = 1;

    string tempUsed = "";
    if (rdoTUsed.SelectedIndex > -1)
    tempUsed = rdoUsed.SelectedItem.Value;
    if (tempUsed == "No")
    rdoUsed = 0;
    else
    rdoUsed = 1;

    CallDate = DateTime.Now;

    ****call method that creates the parameters and calls stored procedure
    InsertRow(strSerialNumber,rdoUsed, cbNoDispatch, cbCaller, dCallDateTime);

    **** the method creates the parameters that go to the stored procedure
    SqlParameter[] Params = {new
    SqlParameter("@StrSerialNumber",strSerialNumber),
    new SqlParameter("@RdoUsed",
    new SqlParameter("@CbNoDispatch",cbNoDispatch),
    new SqlParameter("@CbCaller", cbCaller),
    new SqlParameter("@CallDate", CallDate)};

    **** This is the stoed procedure

    set ANSI_NULLS ON
    set QUOTED_IDENTIFIER ON
    go

    alter PROCEDURE [dbo].[spInsertRow]

    @StrSerialNumber varchar(50),
    @RdoUsed int,
    @CbNoDispatch varchar(1),
    @CbCaller int,
    @CallDate DateTime

    AS
    BEGIN
    Insert into ProblemWorkItem(SerialNumber, LotsUsed, Dispatched ,
    DispatchedBy, CallDate)
    Values(@StrSerialNumber, @RdoUsed, @CbNoDispatch , @CbCaller, @CallDate)
    END

    Note: I put breakpoints in the method that creates the parameters the calls
    the stored procedures so I saw the parameters values and they went to the
    stored procedure when it executed. But the stored procedure didn’t return
    any resultset back. By the way, the CheckBox fields in the table look like
    this:

    LotsUsed int <<<RadioButtonList
    Dispatched char(1) Unchecked <<<CheckBox
    DispatchedBy int Unchecked <<<CheckBox


    What do you think?


    Thanks
    Jeff

    --
    JB
    JB, Feb 25, 2010
    #1
    1. Advertising

  2. Re: Stored procedure wont insert Fields, RadioButtonLists andCheckBox

    On Feb 25, 2:34 am, JB <> wrote:
    > Hello Community
    >
    > I have a CheckBox and a RadioButtonList and fields on an aspx web page form.
    > I pass the fields on the form to a method that creates the parameters and
    > executes a stored procedure and the stored procedure is supposed to insert
    > this information as a row into a table.
    >
    >     For some reason the stored procedure executes but the row does not get
    > inserted.  I can’t see why the row doesn’t get inserted especially since I
    > put BreakPoints in the code all along the way and I see the values just as
    > they get passed into the stored procedure but maybe someone looking at this
    > can see why the row doesn't get inserted or have an idea why a row doesn't
    > insert.  Note: there are more fields in this table than I am showing, these
    > are  just some of the fields that I am inserting into the table  and that are
    > in the table:
    >
    > The only thing I could think of is maybe I can’t insert the values I am
    > trying to  insert into the fields that are defined for the CheckBox and
    > RadioButtonList:
    >
    > **** Initialize variable
    >         string strSerialNumber = "";
    >         string cbNoDispatch = " ";
    >         int cbCaller = 0;
    >         int rdoUsed = 0;
    >         DateTime CallDate = new DateTime();
    >
    > ****get values for variable
    >             strSerialNumber =.GetSerialNum(gval);
    >
    >             if (chkNoDispatch.Checked)
    >                 cbNoDispatch = "Y";
    >             else
    >                 cbNoDispatch = "N";
    >
    >             if (chkCaller.Checked)
    >                 cbCaller = 0;
    >             else
    >                 cbCaller = 1;
    >
    >             string tempUsed = "";
    >             if (rdoTUsed.SelectedIndex > -1)
    >                 tempUsed = rdoUsed.SelectedItem.Value;
    >             if (tempUsed == "No")
    >                 rdoUsed = 0;
    >             else
    >                 rdoUsed = 1;
    >
    >             CallDate = DateTime.Now;
    >
    > ****call method that  creates the parameters and calls stored procedure
    > InsertRow(strSerialNumber,rdoUsed, cbNoDispatch, cbCaller, dCallDateTime);
    >
    > **** the method creates the parameters that go to the stored procedure
    > SqlParameter[] Params = {new
    > SqlParameter("@StrSerialNumber",strSerialNumber),
    >                          new SqlParameter("@RdoUsed",
    >                          new SqlParameter("@CbNoDispatch",cbNoDispatch),
    >                          new SqlParameter("@CbCaller", cbCaller),
    >                  new SqlParameter("@CallDate", CallDate)};
    >
    > **** This is the stoed procedure
    >
    > set ANSI_NULLS ON
    > set QUOTED_IDENTIFIER ON
    > go
    >
    > alter PROCEDURE [dbo].[spInsertRow]
    >
    > @StrSerialNumber   varchar(50),
    > @RdoUsed           int,
    > @CbNoDispatch      varchar(1),
    > @CbCaller          int,
    > @CallDate          DateTime
    >
    > AS
    > BEGIN
    >     Insert into ProblemWorkItem(SerialNumber, LotsUsed, Dispatched ,
    > DispatchedBy, CallDate)
    >     Values(@StrSerialNumber, @RdoUsed,  @CbNoDispatch , @CbCaller, @CallDate)
    > END
    >
    > Note:  I put breakpoints in the method that creates the parameters the calls
    > the stored procedures so I saw the parameters values and they went to the
    > stored procedure when it executed.  But the stored procedure didn’t return
    > any resultset back.  By the way, the CheckBox fields in the table look like
    > this:
    >
    >       LotsUsed          int              <<<RadioButtonList
    >       Dispatched              char(1)   Unchecked    <<<CheckBox
    >       DispatchedBy      int           Unchecked    <<<CheckBox
    >
    > What do you think?
    >
    > Thanks
    > Jeff
    >
    > --
    > JB


    It could be that the date you passed to the sql is not in what sql
    server is expected. Check if specifing the type could help

    SqlParameter parameter = command.Parameters.Add("@CallDate",
    System.Data.SqlDbType.DateTime);
    parameter.Value = DateTime.Now;
    Alexey Smirnov, Feb 28, 2010
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sramruttun

    2 radiobuttonlists for selection

    sramruttun, Aug 6, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    397
    sramruttun
    Aug 6, 2003
  2. Mike P
    Replies:
    0
    Views:
    3,284
    Mike P
    Jun 19, 2006
  3. Replies:
    3
    Views:
    13,928
    raghav
    Sep 6, 2006
  4. jobs
    Replies:
    0
    Views:
    868
  5. Steve

    RadioButtonLists and Javascript

    Steve, Jul 21, 2003, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    120
Loading...

Share This Page