Professional Web Applications Themes

How insert null in numerics fields? - ASP Database

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...

  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. #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

  3. #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" <reb01501NOyahoo.SPAMcom> escreveu na mensagem
    news:#drqGxe1DHA.3824TK2MSFTNGP11.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

  4. #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

  5. #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" <reb01501NOyahoo.SPAMcom> wrote in message
    news:eVUf1Bf1DHA.2528TK2MSFTNGP10.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

  6. #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" <reb01501NOyahoo.SPAMcom> escreveu na mensagem
    news:eVUf1Bf1DHA.2528TK2MSFTNGP10.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

Similar Threads

  1. &nbsp; and null fields in a datagrid
    By Tina in forum ASP.NET Data Grid Control
    Replies: 1
    Last Post: October 19th, 10:40 AM
  2. INSERT Null value problem
    By Targa in forum ASP Database
    Replies: 8
    Last Post: May 15th, 03:50 AM
  3. ASP SQL Insert NULL Date Value
    By Chad S in forum ASP
    Replies: 5
    Last Post: February 19th, 07:33 PM
  4. Replies: 0
    Last Post: November 21st, 04:58 PM
  5. #26351 [NEW]: Incorrect handling of Null Fields/Numerical Fields with '0'
    By jabberwocky at ibplanet dot com in forum PHP Development
    Replies: 0
    Last Post: November 21st, 04:47 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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