How insert null in numerics fields?

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default How insert null in numerics fields?

    Good morning,
    How insert null in numerics fields?
    I can't insert 0()zero and nor other number, because any positive number can
    be a possible code to my system.
    I tried FieldX = Null, but I could not get sucess executing SQL.

    thanks,

    --

    ««««««««»»»»»»»»»»»»»»
    Vlmar Brazăo de Oliveira
    Desenvolvimento Web
    HI-TEC


    Vilmar Brazăo de Oliveira Guest

  2. Similar Questions and Discussions

    1.   and null fields in a datagrid
      in the itemDatabound event of a datagrid, both null fields and blank string come through as   in the e.items.cells field. Is there anyway to...
    2. INSERT Null value problem
      Ive got a form that posts to an Access db and a few of the fields are of "number" type in the database. These fields do not require data to...
    3. ASP SQL Insert NULL Date Value
      Hello, I've been pulling my hair out trying to figure this out. Thank you in advance for taking the time to look at this. I'm trying to...
    4. #26351 [Opn->Bgs]: Incorrect handling of Null Fields/Numerical Fields with '0'
      ID: 26351 Updated by: iliaa@php.net Reported By: jabberwocky at ibplanet dot com -Status: Open +Status: ...
    5. #26351 [NEW]: Incorrect handling of Null Fields/Numerical Fields with '0'
      From: jabberwocky at ibplanet dot com Operating system: Any PHP version: 4.3.4 PHP Bug Type: MSSQL related Bug description: ...
  3. #2

    Default Re: How insert null in numerics fields?

    Vilmar Brazăo de Oliveira wrote:
    > Good morning,
    > How insert null in numerics fields?
    > I can't insert 0()zero and nor other number, because any positive
    > number can be a possible code to my system.
    > I tried FieldX = Null, but I could not get sucess executing SQL.
    >
    > thanks,
    It always helps to tell us what kind of database you are using.

    Does the field/column accept Nulls, i.e., is it a Required field?

    If it accepts Nulls, then usually you can simply exclude the field from the
    columns list in the Insert clause in the SQL statement.
    Altenatively, you can simply do this by using the Null keyword ... oh! I see
    you have tried this. What happens when you do it? Error messages? If so,
    what error message? Show us the code you tried


    Bob Barrows
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Bob Barrows Guest

  4. #3

    Default Re: How insert null in numerics fields?

    hi,
    my database is sql server 2000.
    field:
    1 AgCodEmpresa float 8 1(it accepts null)
    instruction sql:
    SQLNotificacao = "Insert into
    Agenda_Condominios(AgDtHora,AgSeq,AgEmpresa,AgBloc o,AgApto,AgDepartamento,Ag
    Descricao,AgSolucionado,Ag3Dias,Ag2Dias,Ag1Dia,AgE mail,AgEmailsCopia,AgCodEm
    presa,AgNome,AgCodCliente) values ('" _
    & AgDtHora & "'," & AgSeq & "," & AgEmpresa & ",'" & AgBloco & "','" &
    AgApto & "'," & AgDepartamento & ",'" & AgDescricao & "','" & AgSolucionado
    & "','" & Ag3Dias & "','" & Ag2Dias & "','" & Ag1Dia & "','" & AgEmail _
    & "','" & AgEmailsCopia & "'," & AgCodEmpresa & ",'" & AgNome & "'," &
    Session("SiCod") & ")"

    I wouldn´t like to use an conditional IF to check if I have to put the
    numbers fields in select or not.
    thanks your hope,

    --

    ««««««««»»»»»»»»»»»»»»
    Vlmar Brazăo de Oliveira
    Desenvolvimento Web
    HI-TEC

    "Bob Barrows" <reb01501@NOyahoo.SPAMcom> escreveu na mensagem
    news:#drqGxe1DHA.3824@TK2MSFTNGP11.phx.gbl...
    > Vilmar Brazăo de Oliveira wrote:
    > > Good morning,
    > > How insert null in numerics fields?
    > > I can't insert 0()zero and nor other number, because any positive
    > > number can be a possible code to my system.
    > > I tried FieldX = Null, but I could not get sucess executing SQL.
    > >
    > > thanks,
    >
    > It always helps to tell us what kind of database you are using.
    >
    > Does the field/column accept Nulls, i.e., is it a Required field?
    >
    > If it accepts Nulls, then usually you can simply exclude the field from
    the
    > columns list in the Insert clause in the SQL statement.
    > Altenatively, you can simply do this by using the Null keyword ... oh! I
    see
    > you have tried this. What happens when you do it? Error messages? If so,
    > what error message? Show us the code you tried
    >
    >
    > Bob Barrows
    > --
    > Microsoft MVP -- ASP/ASP.NET
    > Please reply to the newsgroup. The email account listed in my From
    > header is my spam trap, so I don't check it very often. You will get a
    > quicker response by posting to the newsgroup.
    >
    >

    Vilmar Brazăo de Oliveira Guest

  5. #4

    Default Re: How insert null in numerics fields?

    Vilmar Brazăo de Oliveira wrote:
    > hi,
    > my database is sql server 2000.
    > field:
    > 1 AgCodEmpresa float 8 1(it accepts null)
    > instruction sql:
    > SQLNotificacao = "Insert into
    >
    Agenda_Condominios(AgDtHora,AgSeq,AgEmpresa,AgBloc o,AgApto,AgDepartamento,Ag
    >
    Descricao,AgSolucionado,Ag3Dias,Ag2Dias,Ag1Dia,AgE mail,AgEmailsCopia,AgCodEm
    > presa,AgNome,AgCodCliente) values ('" _
    > & AgDtHora & "'," & AgSeq & "," & AgEmpresa & ",'" & AgBloco &
    > "','" & AgApto & "'," & AgDepartamento & ",'" & AgDescricao & "','" &
    > AgSolucionado & "','" & Ag3Dias & "','" & Ag2Dias & "','" & Ag1Dia &
    > "','" & AgEmail _ & "','" & AgEmailsCopia & "'," & AgCodEmpresa &
    > ",'" & AgNome & "'," & Session("SiCod") & ")"
    >
    > I wouldn´t like to use an conditional IF to check if I have to put
    > the numbers fields in select or not.
    What does Response.Write SQLNotificacao show?

    Have you tried this:
    If len(AgCodEmpresa) = 0 then AgCodEmpresa = "Null"

    Bob Barrows

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Bob Barrows Guest

  6. #5

    Default Re: How insert null in numerics fields?

    use a function to format your values:


    Function SQLFloat( nIn )

    SQLFloat= "null"

    If Not IsNull( nIn ) Then
    If IsNumeric(nIn) Then
    SQLFloat = CStr(nIn) ' might want to use FormatNumber here
    End If
    End If

    End Function

    Then build your SQL with the function

    ....
    "','" & AgEmail _ & "','" & AgEmailsCopia & "'," & SQLFloat(AgCodEmpresa)
    &
    ....

    --
    Mark Schupp
    Head of Development
    Integrity eLearning
    [url]www.ielearning.com[/url]


    "Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
    news:eVUf1Bf1DHA.2528@TK2MSFTNGP10.phx.gbl...
    > Vilmar Brazăo de Oliveira wrote:
    > > hi,
    > > my database is sql server 2000.
    > > field:
    > > 1 AgCodEmpresa float 8 1(it accepts null)
    > > instruction sql:
    > > SQLNotificacao = "Insert into
    > >
    >
    Agenda_Condominios(AgDtHora,AgSeq,AgEmpresa,AgBloc o,AgApto,AgDepartamento,Ag
    > >
    >
    Descricao,AgSolucionado,Ag3Dias,Ag2Dias,Ag1Dia,AgE mail,AgEmailsCopia,AgCodEm
    > > presa,AgNome,AgCodCliente) values ('" _
    > > & AgDtHora & "'," & AgSeq & "," & AgEmpresa & ",'" & AgBloco &
    > > "','" & AgApto & "'," & AgDepartamento & ",'" & AgDescricao & "','" &
    > > AgSolucionado & "','" & Ag3Dias & "','" & Ag2Dias & "','" & Ag1Dia &
    > > "','" & AgEmail _ & "','" & AgEmailsCopia & "'," & AgCodEmpresa &
    > > ",'" & AgNome & "'," & Session("SiCod") & ")"
    > >
    > > I wouldn´t like to use an conditional IF to check if I have to put
    > > the numbers fields in select or not.
    >
    > What does Response.Write SQLNotificacao show?
    >
    > Have you tried this:
    > If len(AgCodEmpresa) = 0 then AgCodEmpresa = "Null"
    >
    > Bob Barrows
    >
    > --
    > Microsoft MVP -- ASP/ASP.NET
    > Please reply to the newsgroup. The email account listed in my From
    > header is my spam trap, so I don't check it very often. You will get a
    > quicker response by posting to the newsgroup.
    >
    >

    Mark Schupp Guest

  7. #6

    Default Re: How insert null in numerics fields?

    HI Bob and every body else,
    this kind of things runs marvellous OK!
    If len(AgCodEmpresa) = 0 then AgCodEmpresa = "Null"
    OR
    If AgCodEmpresa = "" then AgCodEmpresa = "Null"

    I had forgot the ""(quotation marks)!!
    thanks,

    --

    ««««««««»»»»»»»»»»»»»»
    Vlmar Brazăo de Oliveira
    Desenvolvimento Web
    HI-TEC
    "Bob Barrows" <reb01501@NOyahoo.SPAMcom> escreveu na mensagem
    news:eVUf1Bf1DHA.2528@TK2MSFTNGP10.phx.gbl...
    > Vilmar Brazăo de Oliveira wrote:
    > > hi,
    > > my database is sql server 2000.
    > > field:
    > > 1 AgCodEmpresa float 8 1(it accepts null)
    > > instruction sql:
    > > SQLNotificacao = "Insert into
    > >
    >
    Agenda_Condominios(AgDtHora,AgSeq,AgEmpresa,AgBloc o,AgApto,AgDepartamento,Ag
    > >
    >
    Descricao,AgSolucionado,Ag3Dias,Ag2Dias,Ag1Dia,AgE mail,AgEmailsCopia,AgCodEm
    > > presa,AgNome,AgCodCliente) values ('" _
    > > & AgDtHora & "'," & AgSeq & "," & AgEmpresa & ",'" & AgBloco &
    > > "','" & AgApto & "'," & AgDepartamento & ",'" & AgDescricao & "','" &
    > > AgSolucionado & "','" & Ag3Dias & "','" & Ag2Dias & "','" & Ag1Dia &
    > > "','" & AgEmail _ & "','" & AgEmailsCopia & "'," & AgCodEmpresa &
    > > ",'" & AgNome & "'," & Session("SiCod") & ")"
    > >
    > > I wouldn´t like to use an conditional IF to check if I have to put
    > > the numbers fields in select or not.
    >
    > What does Response.Write SQLNotificacao show?
    >
    > Have you tried this:
    > If len(AgCodEmpresa) = 0 then AgCodEmpresa = "Null"
    >
    > Bob Barrows
    >
    > --
    > Microsoft MVP -- ASP/ASP.NET
    > Please reply to the newsgroup. The email account listed in my From
    > header is my spam trap, so I don't check it very often. You will get a
    > quicker response by posting to the newsgroup.
    >
    >

    Vilmar Brazăo de Oliveira 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