Null values enter to SQL

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Null values enter to SQL


    Hi,

    I have datagrid filled using SqlDataAdapter. One of the fields is a date
    field which can be null.

    When I assign null value I receive the following error:
    "SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and
    12/31/9999 11:59:59 PM."

    My code:
    Dim dateunl As TextBox
    dateunl = CType(e.Item.Cells(11).Controls(0), TextBox)
    If dateunl.Text = "" Then
    dateunloadnew = Nothing
    Else : dateunloadnew = dateunl.Text
    End If

    Dim r As Loadings._Dom_LoadingsRow
    r = Loadings2._Dom_Loadings.FindByid(key)

    r.DateUnload() = dateunloadnew

    SqlDataAdapter1.Update(Loadings2)

    Thanks,

    Movsum

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Movsum Zade Guest

  2. Similar Questions and Discussions

    1. cfgridupdate and null values
      Yeah I have the same problem. It looks like the only solution is to rewrite a custom version cfgridupdate to do my own custom query update. I...
    2. WDDX and NULL values
      I am currently working on a project to upgrade from our ColdFusion server from CF 5.0 to CF MX 7. I've started testing our existing applications...
    3. Null Values
      hi how to count null values in an array? tnx
    4. Detecting Null Values
      I have a DataGrid from which the datasource is a SqlDataReader based on a SQL Server Stored Procedure. This SP returns columns will NULL values. ...
    5. Joining on Null values
      Hello everyone Have a problem that I need help with I have a table Codes which looks like: ID, Code, modifier Any code can have multiple...
  3. #2

    Default Re: Null values enter to SQL

    assgin DBNull in VB.NEt you will be fine.

    >-----Original Message-----
    >I do not know how in VB, but in C# you could
    >
    >if (dateunl.Text.Equals(string.Empty)){
    > dateunloadnew = System.Data.SqlTypes.SqlDateTime.Null;
    >}
    >
    >Vaclav
    >
    >
    >"Movsum Zade" <mmzade@socarmo.az> wrote in message
    >news:%23LTKXnPVDHA.1896@TK2MSFTNGP12.phx.gbl...
    >>
    >> Hi,
    >>
    >> I have datagrid filled using SqlDataAdapter. One of the
    fields is a date
    >> field which can be null.
    >>
    >> When I assign null value I receive the following error:
    >> "SqlDateTime overflow. Must be between 1/1/1753
    12:00:00 AM and
    >> 12/31/9999 11:59:59 PM."
    >>
    >> My code:
    >> Dim dateunl As TextBox
    >> dateunl = CType(e.Item.Cells(11).Controls(0),
    TextBox)
    >> If dateunl.Text = "" Then
    >> dateunloadnew = Nothing
    >> Else : dateunloadnew = dateunl.Text
    >> End If
    >>
    >> Dim r As Loadings._Dom_LoadingsRow
    >> r = Loadings2._Dom_Loadings.FindByid(key)
    >>
    >> r.DateUnload() = dateunloadnew
    >>
    >> SqlDataAdapter1.Update(Loadings2)
    >>
    >> Thanks,
    >>
    >> Movsum
    >>
    >> *** Sent via Developersdex [url]http://www.developersdex.com[/url]
    ***
    >> Don't just participate in USENET...get rewarded for it!
    >
    >
    >.
    >
    DudeGuy Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139