www.webdeveloper.com
Results 1 to 4 of 4

Thread: putting the formMail submmission to a database

  1. #1
    Join Date
    Jun 2005
    Posts
    86

    submit to an access database

    hello guys!

    i have a webform that will submit the information into access database, but am getting this error when i hit the submit button:

    Error Type:
    Microsoft JET Database Engine (0x80004005)
    Operation must use an updateable query.
    /asp/project/BasicForm.asp, line 35

    my form and database connection looks like this:

    PHP Code:
    <%@ LANGUAGE="VBScript" %>
    <%
    Option Explicit%>
    <
    html>
    <
    body>
    <%

    'This function prepares a string for being used in a SQL statement.
    Function SafeForSQL(strIn)
        SafeForSQL = Replace(strIn, "'", "''")
    End Function


    If Request.Form("
    cmdSubmit") <> "" Then
    'The user has submitted data, save that information to the database
    '  This process does not check for data duplication, it does a "
    blind" data dump.

        Dim con, strCon, strSql, strDatabasePath

    'MODIFY: Set this to be the relative path to your database
        strDatabasePath = "
    BasicForm.mdb"

    'Connect to the Access database using a DSN-Less connection
        Set con = Server.CreateObject("
    ADODB.Connection")    
        strCon = "
    PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & Server.MapPath(strDatabasePath)    
        con.Open strCon
        
    'Generate the SQL string to store the data
        strSql =    "
    INSERT INTO FormData (FirstNameLastNameEmailComments" + _
                    "
    VALUES ('" + SafeForSQL(Request.Form("txtFirstName")) + "'" + _
                    "'" + SafeForSQL(Request.Form("txtLastName")) + "'
    " + _
                    "'" + SafeForSQL(Request.Form("txtEmail")) + "'
    " + _
                    "'" + SafeForSQL(Request.Form("txtComments")) + "'
    )"

    'Execute the SQL statement
        con.Execute(strSql)
        
    'Clean up database objects
        con.Close
        Set con = Nothing
    %>

        Display information (HTML) here that you would like displayed upon successfully adding the 
        information to the database.

    <%
    Else
    'The user has not submitted the page, so display the form
    %>

        <form name="
    frmMain" action="BasicForm.asp" method="post">
            <table>
            <tr>
                <td>First Name:</td>
                <td><input type="
    text" name="txtFirstName" value=""></td>
            </tr>
            <tr>
                <td>Last Name:</td>
                <td><input type="
    text" name="txtLastName" value=""></td>
            </tr>
            <tr>
                <td>Email:</td>
                <td><input type="
    text" name="txtEmail" value=""></td>
            </tr>
            <tr>
                <td colspan="
    2">
                    Comments:<br />
                    <textarea name="
    txtComments" cols="50" rows="10"></textarea>
                </td>
            </tr>
            <tr>
                <td colspan="
    2" align="right"><input type="submit" name="cmdSubmit" value="Submit"></td>
            </tr>
            </table>    
        </form>
    <%    
    End If
    %>

    </body>
    </html> 
    Last edited by blakeph; 06-10-2005 at 07:00 AM.

  2. #2
    Join Date
    Dec 2004
    Posts
    8,637
    I'd guess that the database itself doesn't allow updates or the permissions for the folder the database is in are not set to allow you to update the database. Talk to your host.

  3. #3
    Join Date
    Jun 2005
    Posts
    86
    thanks phpnovice! you're right, there was a problem with read/write permission to the database.

  4. #4
    Join Date
    Dec 2004
    Posts
    8,637

    Thumbs up You're welcome!

    Cheers.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles