ADODB error from JS

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Adrian

    ADODB error from JS

    Hi,
    I have an ASP page on an intranet IIS server that posts data via a
    System DSN to an Access DB, normally it works fine however sometimes it
    returns 0 for success but no data is added to the DB!?

    Dim conn
    Set conn = Server.CreateOb ject("ADODB.Con nection")
    conn.Open "DSN=testma in"
    sql="Insert Into testtable (Survey_1,Surve y_2)
    VALUES ("
    sql=sql & "'" & Request.Form("S urvey_1") & "',"
    sql=sql & "'" & Request.Form("S urvey_2") & "')"
    on error resume next
    conn.Execute sql,recaffected
    if err<>0 then
    Response.Write( " Survey NOT Added! ")
    else
    Response.Write( "<h3>" & recaffected & " Survey Added </h3>")
    end if
    conn.close
    Set conn = Nothing
    %>


    The above is cut down version as there are a lot of fields!

    Anyone know why it would return 0 sometimes but not add the data?

    thanks

    Adrian


  • Laurent Bugnion, GalaSoft

    #2
    Re: ADODB error from JS

    Hi,

    Adrian wrote:[color=blue]
    > Hi,
    > I have an ASP page on an intranet IIS server that posts data via a
    > System DSN to an Access DB, normally it works fine however sometimes it
    > returns 0 for success but no data is added to the DB!?
    >
    > Dim conn
    > Set conn = Server.CreateOb ject("ADODB.Con nection")
    > conn.Open "DSN=testma in"
    > sql="Insert Into testtable (Survey_1,Surve y_2)
    > VALUES ("
    > sql=sql & "'" & Request.Form("S urvey_1") & "',"
    > sql=sql & "'" & Request.Form("S urvey_2") & "')"
    > on error resume next
    > conn.Execute sql,recaffected
    > if err<>0 then
    > Response.Write( " Survey NOT Added! ")
    > else
    > Response.Write( "<h3>" & recaffected & " Survey Added </h3>")
    > end if
    > conn.close
    > Set conn = Nothing
    > %>
    >
    >
    > The above is cut down version as there are a lot of fields!
    >
    > Anyone know why it would return 0 sometimes but not add the data?
    >
    > thanks
    >
    > Adrian[/color]

    You're very much off-topic here. Your code is VBScript on ASP. Ask a VB
    newsgroup, or an ASP newsgroup, or both.

    Laurent
    --
    Laurent Bugnion, GalaSoft
    Webdesign, Java, JavaScript: http://www.galasoft-LB.ch
    Private/Malaysia: http://mypage.bluewin.ch/lbugnion
    Support children in Calcutta: http://www.calcutta-espoir.ch

    Comment

    • Adrian

      #3
      Re: ADODB error from JS


      "Laurent Bugnion, GalaSoft" <galasoft-LB@bluewin_NO_S PAM.ch> wrote in
      message news:3F1FF4DF.4 030304@bluewin_ NO_SPAM.ch...[color=blue]
      > Hi,
      >
      > Adrian wrote:[color=green]
      > > Hi,
      > > I have an ASP page on an intranet IIS server that posts data via a
      > > System DSN to an Access DB, normally it works fine however sometimes it
      > > returns 0 for success but no data is added to the DB!?
      > >
      > > Dim conn
      > > Set conn = Server.CreateOb ject("ADODB.Con nection")
      > > conn.Open "DSN=testma in"
      > > sql="Insert Into testtable (Survey_1,Surve y_2)
      > > VALUES ("
      > > sql=sql & "'" & Request.Form("S urvey_1") & "',"
      > > sql=sql & "'" & Request.Form("S urvey_2") & "')"
      > > on error resume next
      > > conn.Execute sql,recaffected
      > > if err<>0 then
      > > Response.Write( " Survey NOT Added! ")
      > > else
      > > Response.Write( "<h3>" & recaffected & " Survey Added </h3>")
      > > end if
      > > conn.close
      > > Set conn = Nothing
      > > %>
      > >
      > >
      > > The above is cut down version as there are a lot of fields!
      > >
      > > Anyone know why it would return 0 sometimes but not add the data?
      > >
      > > thanks
      > >
      > > Adrian[/color]
      >
      > You're very much off-topic here. Your code is VBScript on ASP. Ask a VB
      > newsgroup, or an ASP newsgroup, or both.
      >
      > Laurent
      > --
      > Laurent Bugnion, GalaSoft
      > Webdesign, Java, JavaScript: http://www.galasoft-LB.ch
      > Private/Malaysia: http://mypage.bluewin.ch/lbugnion
      > Support children in Calcutta: http://www.calcutta-espoir.ch
      >[/color]


      Opps Sorry!


      Comment

      • kaeli

        #4
        Re: ADODB error from JS

        In article <bfor4m$cei$1$8 302bc10@news.de mon.co.uk>,
        Adrian_Gardener @NOSPAMhotamil. com enlightened us with...[color=blue]
        > Hi,
        > I have an ASP page on an intranet IIS server that posts data via a
        > System DSN to an Access DB, normally it works fine however sometimes it
        > returns 0 for success but no data is added to the DB!?
        >
        > Dim conn
        > Set conn = Server.CreateOb ject("ADODB.Con nection")
        > conn.Open "DSN=testma in"
        > sql="Insert Into testtable (Survey_1,Surve y_2)
        > VALUES ("
        > sql=sql & "'" & Request.Form("S urvey_1") & "',"
        > sql=sql & "'" & Request.Form("S urvey_2") & "')"[/color]

        You aren't testing to be sure the values are there.
        Blanks count as values. And if it isn't filled in at all, it gets the
        empty string. Are you sure it isn't inserting blanks/null?

        Dim s1
        s1 = Request.Form("S urvey_1")
        s1 = s1.Trim()
        If s1.Len < 1 Then
        Error
        End If

        --
        -------------------------------------------------
        ~kaeli~
        Black holes were created when God divided by 0.
        Not one shred of evidence supports the notion
        that life is serious.


        -------------------------------------------------

        Comment

        • Adrian

          #5
          Re: ADODB error from JS

          Hi Kaeli
          Thanks for your reply, good point, but alas not the case as no record is
          added not even a blank one! in fact some of the fields are Drop downs so I
          would and do get records with just the defaults. but the problem I have it
          comes back 0 so no error is generated and the user thinks they have
          completed the form OK!!!

          thanks

          Adrian

          "kaeli" <infinite.possi bilities@NOSPAM att.net> wrote in message
          news:MPG.1989b4 b0bc6d202998974 7@nntp.lucent.c om...[color=blue]
          > In article <bfor4m$cei$1$8 302bc10@news.de mon.co.uk>,
          > Adrian_Gardener @NOSPAMhotamil. com enlightened us with...[color=green]
          > > Hi,
          > > I have an ASP page on an intranet IIS server that posts data via a
          > > System DSN to an Access DB, normally it works fine however sometimes it
          > > returns 0 for success but no data is added to the DB!?
          > >
          > > Dim conn
          > > Set conn = Server.CreateOb ject("ADODB.Con nection")
          > > conn.Open "DSN=testma in"
          > > sql="Insert Into testtable (Survey_1,Surve y_2)
          > > VALUES ("
          > > sql=sql & "'" & Request.Form("S urvey_1") & "',"
          > > sql=sql & "'" & Request.Form("S urvey_2") & "')"[/color]
          >
          > You aren't testing to be sure the values are there.
          > Blanks count as values. And if it isn't filled in at all, it gets the
          > empty string. Are you sure it isn't inserting blanks/null?
          >
          > Dim s1
          > s1 = Request.Form("S urvey_1")
          > s1 = s1.Trim()
          > If s1.Len < 1 Then
          > Error
          > End If
          >
          > --
          > -------------------------------------------------
          > ~kaeli~
          > Black holes were created when God divided by 0.
          > Not one shred of evidence supports the notion
          > that life is serious.
          > http://www.ipwebdesign.net/wildAtHeart
          > http://www.ipwebdesign.net/kaelisSpace
          > -------------------------------------------------[/color]


          Comment

          Working...