Handling NULL Dates and other Data on Update grid

Discussion in 'ASP .Net Datagrid Control' started by Ryan Anderson, Jul 18, 2003.

  1. I am looking for an example that displays the proper way to handle NULL date
    vaules
    when working with updating the data grid;

    When updating a record I am returning the field values;

    Dim dCloseDate As Date = CType(e.Item.FindControl("cm_R_CLSEDATE"),
    TextBox).Text
    Dim iRate As String = CType(e.Item.FindControl("cm_R_RATE"), TextBox).Text
    Dim iLoanAmount As Integer = CType(e.Item.FindControl("cm_R_LOANAMT"),
    TextBox).Text

    ' Setting up the SP parameters
    paramsToStore(3) = New SqlParameter("@cm_R_CLSEDATE", SqlDbType.Datetime)
    paramsToStore(4) = New SqlParameter("@cm_R_RATE", SqlDbType.Float)
    paramsToStore(5) = New SqlParameter("@curLoanAmount", SqlDbType.Float)

    ' Retrieving the parameters from the cache
    storedParams(3).Value = dCloseDate
    storedParams(4).Value = iRate
    storedParams(5).Value = iLoanAmount

    ' Using the MS Data Application Block
    Dim ds As DataSet
    ds = SqlHelper.ExecuteDataset(sDBConnString, CommandType.StoredProcedure,
    sql, storedParams)

    I either blow up here with the date if it's NULL
    String was not recognized as a valid DateTime.
    'fill the DataSet using default values for DataTable names, etc.
    Line 462: da.Fill(ds)

    When the date field in left blank, which is in the application Block code Or
    here;
    Input string was not in a correct format.
    System.FormatException: Input string was not in a correct format.
    Line 243: Dim iLoanAmount As Integer =
    CType(e.Item.FindControl("cm_R_LOANAMT"), TextBox).Text

    I am not that savy in .NET and I am unsure how to properly handle these NULL
    values when I update the DB.
    Please let me know if you have a better way of doing it, or have an link to
    a high speed example!

    Much thanks for your time!
    Ryan
    Marina Mortgage
    La Jolla, CA USA
     
    Ryan Anderson, Jul 18, 2003
    #1
    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. David Lozzi

    Dates dates dates dates... SQL and ASP.NET

    David Lozzi, Sep 29, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    910
    Rob Schieber
    Sep 30, 2005
  2. Replies:
    5
    Views:
    27,589
    Mike Schilling
    Mar 29, 2006
  3. PW

    Dates! Dates! Dates!

    PW, Aug 7, 2004, in forum: ASP General
    Replies:
    4
    Views:
    235
    Mark Schupp
    Aug 9, 2004
  4. Replies:
    1
    Views:
    240
    Jano Svitok
    Jul 17, 2007
  5. kellygreer1

    RFC-822 dates into Ruby dates

    kellygreer1, Jun 8, 2008, in forum: Ruby
    Replies:
    1
    Views:
    265
    Eric I.
    Jun 8, 2008
Loading...

Share This Page