Professional Web Applications Themes

Updating Database with ASP - Macromedia Dreamweaver

Hi, I'm just learning how to use ASP and I've been trying to figure out how to add records to my database. I'm learning it out of a book and have been following the code in the book except IT DOESNT WORK!!!! I have no idea why. It's maddening! My update code is attached for your kindly inspection. Thanks for whatever help you can provide. I'll need it. <%LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <% Option Explicit %> <% Dim Connect, msgRS, Query Set Connect = Server.CreateObject("ADODB.Connection") Connect.Open "appData1" Set msgRS = Server.CreateObject("ADODB.Recordset") Query = "SELECT * FROM helloWorld" msgRS.Open Query, Connect, adOpenStatic, _ ...

  1. #1

    Default Updating Database with ASP

    Hi,

    I'm just learning how to use ASP and I've been trying to figure out how to add records to my database.

    I'm learning it out of a book and have been following the code in the book except IT DOESNT WORK!!!!

    I have no idea why. It's maddening!

    My update code is attached for your kindly inspection.

    Thanks for whatever help you can provide. I'll need it.
    <%LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <% Option Explicit %>

    <%
    Dim Connect, msgRS, Query
    Set Connect = Server.CreateObject("ADODB.Connection")
    Connect.Open "appData1"
    Set msgRS = Server.CreateObject("ADODB.Recordset")
    Query = "SELECT * FROM helloWorld"
    msgRS.Open Query, Connect, adOpenStatic, _
    adLockOptimistic

    msgRS.AddNew
    msgRS("name") = "John Doe"
    msgRS("Message") = "Ya did a great jeaoaearb there!"
    msgRS.Update
    %>

    ------------------
    All that is gold does not glitter
    Not all who wander are lost . . .

    -- J. R. R. Tolkien

    Mithrandir webforumsuser@macromedia.com Guest

  2. #2

    Default Re: Updating Database with ASP

    All your code is doing is reading all the records from a table called
    HelloWorld. You need an insert statement to write to it.

    Rather than trying to hand code it, I would look at upgradings to DMX, as
    all this functionality is built in.

    --
    Regards

    Paul Whitham
    Valleybiz Internet Design
    [url]www.valleybiz.net[/url]

    Team Macromedia Volunteer for Ultradev/Dreamweaver MX
    [url]www.macromedia.com/support/forums/team_macromedia[/url]
    "Mithrandir" <webforumsusermacromedia.com> wrote in message
    news:bf2hbv$5qr$1forums.macromedia.com...
    > Hi,
    >
    > I'm just learning how to use ASP and I've been trying to figure out how to
    add records to my database.
    >
    > I'm learning it out of a book and have been following the code in the book
    except IT DOESNT WORK!!!!
    >
    > I have no idea why. It's maddening!
    >
    > My update code is attached for your kindly inspection.
    >
    > Thanks for whatever help you can provide. I'll need it.
    > <%LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    > <% Option Explicit %>
    >
    > <%
    > Dim Connect, msgRS, Query
    > Set Connect = Server.CreateObject("ADODB.Connection")
    > Connect.Open "appData1"
    > Set msgRS = Server.CreateObject("ADODB.Recordset")
    > Query = "SELECT * FROM helloWorld"
    > msgRS.Open Query, Connect, adOpenStatic, _
    > adLockOptimistic
    >
    > msgRS.AddNew
    > msgRS("name") = "John Doe"
    > msgRS("Message") = "Ya did a great jeaoaearb there!"
    > msgRS.Update
    > %>
    >
    > ------------------
    > All that is gold does not glitter
    > Not all who wander are lost . . .
    >
    > -- J. R. R. Tolkien
    >

    Paul Whitham TMM Guest

  3. #3

    Default Re: Updating Database with ASP

    Go to [url]www.webthang.co.uk[/url] , there is a tutorial on ASP using DWMX. Really
    easy.

    cheers
    vivian


    "Mithrandir" <webforumsusermacromedia.com> wrote in message
    news:bf2hbv$5qr$1forums.macromedia.com...
    > Hi,
    >
    > I'm just learning how to use ASP and I've been trying to figure out how to
    add records to my database.
    >
    > I'm learning it out of a book and have been following the code in the book
    except IT DOESNT WORK!!!!
    >
    > I have no idea why. It's maddening!
    >
    > My update code is attached for your kindly inspection.
    >
    > Thanks for whatever help you can provide. I'll need it.
    > <%LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    > <% Option Explicit %>
    >
    > <%
    > Dim Connect, msgRS, Query
    > Set Connect = Server.CreateObject("ADODB.Connection")
    > Connect.Open "appData1"
    > Set msgRS = Server.CreateObject("ADODB.Recordset")
    > Query = "SELECT * FROM helloWorld"
    > msgRS.Open Query, Connect, adOpenStatic, _
    > adLockOptimistic
    >
    > msgRS.AddNew
    > msgRS("name") = "John Doe"
    > msgRS("Message") = "Ya did a great jeaoaearb there!"
    > msgRS.Update
    > %>
    >
    > ------------------
    > All that is gold does not glitter
    > Not all who wander are lost . . .
    >
    > -- J. R. R. Tolkien
    >

    Vivian Mark Guest

  4. #4

    Default Re: Updating Database with ASP

    So I unchecked "show friendly http errors" and this error message was revealed.

    Microsoft VBScript runtime error '800a01f4'

    Variable is undefined: 'adOpenStatic'

    /asp/funandgames3-1-processor.asp, line 10

    It seems to think that adOpenStatic is a variable. I just read in my book it's a constant and I have to include this file called adovbs.inc at the top of my page when I use ADOs.

    The guy at my ISP seemed not to know what I was talking about and said "You should use a datasource".

    So I'm thinking I cant really use the code from my book so maybe I'll try the code you suggest and see how it goes.

    Thanks.

    ------------------
    All that is gold does not glitter
    Not all who wander are lost . . .

    -- J. R. R. Tolkien

    Mithrandir webforumsuser@macromedia.com Guest

  5. #5

    Default Re: Updating Database with ASP

    So I've got a whole new issue to deal with.

    How do I use the code you suggested to insert form data into the database.

    I've tried some things and nothing works.

    My book uses code that's really different from what you use so it's no help.

    Any suggestions would be most welcome.


    ------------------
    All that is gold does not glitter
    Not all who wander are lost . . .

    -- J. R. R. Tolkien

    Mithrandir webforumsuser@macromedia.com Guest

  6. #6

    Default Re: Updating Database with ASP

    > Microsoft VBScript runtime error '800a01f4'
    >
    > Variable is undefined: 'adOpenStatic'
    ahhh...I didn't notice that. Do this, go to c:\program files\common
    files\system\ado\adovbs.inc and open that file with Notepad. Use the Find
    feature in that file to find "adOpenStatic". When you find it, note what the
    numerical value is for that constant variable. Replace the word
    "adOpenStatic" in your code with that numerical value.

    The constants defined in that file are meant to provide developers with an
    easy of knowing what the numerical values are.

    --
    Ron


    Ron Guest

  7. #7

    Default Re: Updating Database with ASP

    I wanted to ask you about the code you used:

    1) Is your DSN named "appData1"
    2) Is your database table named "helloWorld"
    3) Is the field in that table named "name", and "Message

    I know your just getting started with ASP, but just wanted to make sure that
    those are correct.

    --
    Ron


    Ron Guest

Similar Threads

  1. updating a database.
    By Samurai_Sjakkie in forum Coldfusion Database Access
    Replies: 7
    Last Post: April 27th, 09:01 PM
  2. updating database
    By MoparMarc in forum Coldfusion Database Access
    Replies: 6
    Last Post: July 14th, 11:41 PM
  3. Updating a Database
    By John H in forum ASP.NET Data Grid Control
    Replies: 0
    Last Post: August 19th, 10:45 PM
  4. Updating database information
    By Geoff Wickens in forum ASP Database
    Replies: 1
    Last Post: August 28th, 02:45 PM
  5. Updating an 'archive' database
    By David Taylor in forum Microsoft SQL / MS SQL Server
    Replies: 1
    Last Post: July 11th, 06:21 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