insert data into database

Ask a Question related to Dreamweaver AppDev, Design and Development.

  1. #1

    Default insert data into database

    :confused;

    Please help, I haven't got a clue what I am doing. I have a page that I wish
    people to enter data then submit it to a Microsoft SQL database. When they
    submit the data I also want another web page to open showing the the whole
    contents of the table. I think my code is a mess and when ever I preview it I
    get this error;

    Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

    [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near
    ','.

    /TMPc5b7nd53g8.asp, line 33

    For all the good it will do here is my code;

    <%@LANGUAGE="VBSCRIPT"%>
    <!--#include file="Connections/directory.asp" -->
    <%
    Dim Recordset1
    Dim Recordset1_numRows

    Set Recordset1 = Server.CreateObject("ADODB.Recordset")
    Recordset1.ActiveConnection = MM_directory_STRING
    Recordset1.Source = "SELECT * FROM dbo.orgtest"
    Recordset1.CursorType = 0
    Recordset1.CursorLocation = 2
    Recordset1.LockType = 1
    Recordset1.Open()

    Recordset1_numRows = 0
    %>
    <!--#include file="Connections/directory.asp" -->
    <%
    if(Request("txtorg") <> "") then Command1__varorgname = Request("txtorg")

    if(Request("txttown") <> "") then Command1__vartown = Request("txttown")
    %>
    <%
    'If Err <> 0 then
    'Response.Write("Error: " & Err.Description)
    %>
    <%
    set Command1 = Server.CreateObject("ADODB.Command")
    Command1.ActiveConnection = MM_directory_STRING
    Command1.CommandText = "INSERT INTO dbo.orgtest (orgname, town) VALUES (" +
    Replace(Command1__varorgname, "'", "''") + ", " + Replace(Command1__vartown,
    "'", "''") + ") "
    Command1.CommandType = 1
    Command1.CommandTimeout = 0
    Command1.Prepared = true
    Command1.Execute()

    %>
    <% If Request("Submit") <> "" Then %>
    <%
    COMMAND CODE
    %>
    <% End If %>
    <form name="form1" method="post" action="inserttest.asp">
    <input name="txtorg" type="text" id="txtorg">
    <input name="txttown" type="text" id="txttown">
    <input type="submit" name="Submit" value="Submit">
    </form>
    <%
    Recordset1.Close()
    Set Recordset1 = Nothing
    %>


    Any help would be greatly appreciated!

    PaulCoyney Guest

  2. Similar Questions and Discussions

    1. Using Flash to insert data into a MS Access database
      Hi, first of all I am using Flash MX 2004 and have Office 2003. I am trying to use my flash form to insert data into a ms access database but it...
    2. how to insert data into database from flashform
      i have create checkbox in flash form, but i can't use the same name for each value, so i make it cb1, cb2, how should i write the sql statement for...
    3. how to insert data into database
      i already make a form and database with access...and now i want to know how the data will insert automatically into the database...another one, how...
    4. How to insert datatable data into database at a time
      Hi TO All I am doing one task, in that i want to insert datatable data int database at a time.i.e., i am creating one datatable and i a...
    5. How to INSERT XML data into Oracle database
      Hi, Working on a solution where we are using XML as a means to export and import various data. Are Using ADO to save to (export ) XML using...
  3. #2

    Default Re: insert data into database

    For starters, you have two connection strings in your page .. one on line
    two where it should be and another down about 15 lines .. take out the
    second one . although there are probably more problems. But start there.


    --
    Nancy Gill
    Team Macromedia Volunteer for Dreamweaver MX/UltraDev
    [url]http://www.macromedia.com/go/team/[/url]
    Co-Author: Dreamweaver MX: Instant Troubleshooter (August, 2003)
    Technical Editor: DMX 2004: The Complete Reference, DMX 2004: A Beginner's
    Guide, Mastering Macromedia Contribute
    Technical Reviewer: Dynamic Dreamweaver MX/DMX: Advanced PHP Web Development

    "PaulCoyney" <webforumsuser@macromedia.com> wrote in message
    news:d0pkpg$mci$1@forums.macromedia.com...
    > :confused;
    >
    > Please help, I haven't got a clue what I am doing. I have a page that I
    wish
    > people to enter data then submit it to a Microsoft SQL database. When they
    > submit the data I also want another web page to open showing the the whole
    > contents of the table. I think my code is a mess and when ever I preview
    it I
    > get this error;
    >
    > Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
    >
    > [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax
    near
    > ','.
    >
    > /TMPc5b7nd53g8.asp, line 33
    >
    > For all the good it will do here is my code;
    >
    > <%@LANGUAGE="VBSCRIPT"%>
    > <!--#include file="Connections/directory.asp" -->
    > <%
    > Dim Recordset1
    > Dim Recordset1_numRows
    >
    > Set Recordset1 = Server.CreateObject("ADODB.Recordset")
    > Recordset1.ActiveConnection = MM_directory_STRING
    > Recordset1.Source = "SELECT * FROM dbo.orgtest"
    > Recordset1.CursorType = 0
    > Recordset1.CursorLocation = 2
    > Recordset1.LockType = 1
    > Recordset1.Open()
    >
    > Recordset1_numRows = 0
    > %>
    > <!--#include file="Connections/directory.asp" -->
    > <%
    > if(Request("txtorg") <> "") then Command1__varorgname = Request("txtorg")
    >
    > if(Request("txttown") <> "") then Command1__vartown = Request("txttown")
    > %>
    > <%
    > 'If Err <> 0 then
    > 'Response.Write("Error: " & Err.Description)
    > %>
    > <%
    > set Command1 = Server.CreateObject("ADODB.Command")
    > Command1.ActiveConnection = MM_directory_STRING
    > Command1.CommandText = "INSERT INTO dbo.orgtest (orgname, town) VALUES
    (" +
    > Replace(Command1__varorgname, "'", "''") + ", " +
    Replace(Command1__vartown,
    > "'", "''") + ") "
    > Command1.CommandType = 1
    > Command1.CommandTimeout = 0
    > Command1.Prepared = true
    > Command1.Execute()
    >
    > %>
    > <% If Request("Submit") <> "" Then %>
    > <%
    > COMMAND CODE
    > %>
    > <% End If %>
    > <form name="form1" method="post" action="inserttest.asp">
    > <input name="txtorg" type="text" id="txtorg">
    > <input name="txttown" type="text" id="txttown">
    > <input type="submit" name="Submit" value="Submit">
    > </form>
    > <%
    > Recordset1.Close()
    > Set Recordset1 = Nothing
    > %>
    >
    >
    > Any help would be greatly appreciated!
    >

    Nancy Gill Guest

  4. #3

    Default Re: insert data into database

    Thanks for the tip, don't know how I missed that. Must be getting somewhere
    cause the error I get is different.

    Microsoft VBScript compilation error '800a03f6'

    Expected 'End'

    /TMP92woqd71p8.asp, line 51

    I have not typed any of this code in I have been using insert and the rest to
    do it so I do not know what it means by Expected 'End', maybe I should go back
    to just fixing computers.

    PaulCoyney 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