Trouble inserting data in database

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

  1. #1

    Default Trouble inserting data in database

    I use DW 2004, XP with sp2, and Access 2003. Im planning to make a site that is
    possible to log in and update news from the web. So I have made a login page, a
    insert, update and delete page, and also a master/detail page which is supposed
    to show the data that has been inserted or updated. I have used templates and
    ASP VBscript.

    When I write data directtly into the database using Access all data shows
    perfectly on the web-page. But when I try to insert or update data using the
    login on the web-site, nothing happens. I get redirected to my confirm-page,
    but when I look at the master/detail page, only the data that I wrote into
    Access shows. It seems to me that the data I am trying to insert when Im using
    the web page doesnt get into the database somehow. I am using my computer as
    testing server on IIS. Does anybody have a suggestion?

    Sonic-x Guest

  2. Similar Questions and Discussions

    1. Having trouble inserting/updating, please look @ code
      Hello, I'm getting an error while trying to insert a record from a form, or update a record from the datagrid. ERROR: at...
    2. Trouble Inserting Page Spreads
      I always have a real hard time inserting page spreads into a document. What am I doing wrong? Say I have a 20 page magazine document. If I want to...
    3. Inserting data from a form to an MS access database
      I'm new to coldfusion, and have run into a problem when trying to insert data from a basic HTML form into an MS Access database. The problem is...
    4. Trouble inserting date into database
      The date format in the form being submitted is mm/dd/yyyy. Below is the error I'm getting. Any help would make me really happy! Thanks Error...
    5. Inserting data from text file into database
      Is it possible to write a script in an ASP page that reads a comma delimited text file and inserts the data row by row into an Access db? Each comma...
  3. #2

    Default Re: Trouble inserting data in database

    Sonic-x wrote:
    > I use DW 2004, XP with sp2, and Access 2003. Im planning to make a site that is
    > possible to log in and update news from the web. So I have made a login page, a
    > insert, update and delete page, and also a master/detail page which is supposed
    > to show the data that has been inserted or updated. I have used templates and
    > ASP VBscript.
    >
    > When I write data directtly into the database using Access all data shows
    > perfectly on the web-page. But when I try to insert or update data using the
    > login on the web-site, nothing happens. I get redirected to my confirm-page,
    > but when I look at the master/detail page, only the data that I wrote into
    > Access shows. It seems to me that the data I am trying to insert when Im using
    > the web page doesnt get into the database somehow. I am using my computer as
    > testing server on IIS. Does anybody have a suggestion?
    >
    Hi,

    You might have been requesting fields (through Request.Form("myField"))
    on your confirmation page, whereas the fields are actually on the input
    page. But anyway, it's a bit difficult to guess without having more
    details on your pages. Give us more info, then we might be able to help
    you in a better way.

    regards
    bernard
    bthouin Guest

  4. #3

    Default Re: Trouble inserting data in database

    Ok, I will try to give your more information :)

    Here is the code on the insert "information" page. Maybe it explains some
    more..

    <!-- InstanceEndEditable --></td>
    </tr>
    <tr><!-- row 5 -->
    <td valign="top"><!-- InstanceBeginEditable name="br?dtekst" -->
    <script language="javascript"
    src="../../ScriptLibrary/incPureUpload.js"></script>
    <p>LEGG INN INFORMASJON</p>
    <p>&nbsp;</p>

    <form action="<%=MM_editAction%>" method="post"
    enctype="multipart/form-data" name="form1"
    onSubmit="checkFileUpload(this,'GIF,JPG,JPEG,BMP,P NG',false,'','','','','','',''
    );return document.MM_returnValue">
    <table align="center">
    <tr valign="baseline">
    <td nowrap align="right">Velg kategori:</td>
    <td><select name="select">
    <%
    While (NOT rsKategori.EOF)
    %>
    <option
    value="<%=(rsKategori.Fields.Item("kategoriType"). Value)%>" <%If (Not
    isNull((rsKategori.Fields.Item("kategoriID").Value ))) Then If
    (CStr(rsKategori.Fields.Item("kategoriType").Value ) =
    CStr((rsKategori.Fields.Item("kategoriID").Value)) ) Then
    Response.Write("SELECTED") : Response.Write("")%>
    ><%=(rsKategori.Fields.Item("kategoriType").Value) %></option>
    <%
    rsKategori.MoveNext()
    Wend
    If (rsKategori.CursorType > 0) Then
    rsKategori.MoveFirst
    Else
    rsKategori.Requery
    End If
    %>

    Sonic-x Guest

  5. #4

    Default Re: Trouble inserting data in database

    Here is the code in the heading. <%@LANGUAGE="VBSCRIPT"%>
    <%
    ' *** Restrict Access To Page: Grant or deny access to this page
    MM_authorizedUsers=""
    MM_authFailedURL="../logginn.asp"
    MM_grantAccess=false
    If Session("MM_Username") <> "" Then
    If (true Or CStr(Session("MM_UserAuthorization"))="") Or _
    (InStr(1,MM_authorizedUsers,Session("MM_UserAuthor ization"))>=1) Then
    MM_grantAccess = true
    End If
    End If
    If Not MM_grantAccess Then
    MM_qsChar = "?"
    If (InStr(1,MM_authFailedURL,"?") >= 1) Then MM_qsChar = "&"
    MM_referrer = Request.ServerVariables("URL")
    if (Len(Request.QueryString()) > 0) Then MM_referrer = MM_referrer & "?" &
    Request.QueryString()
    MM_authFailedURL = MM_authFailedURL & MM_qsChar & "accessdenied=" &
    Server.URLEncode(MM_referrer)
    Response.Redirect(MM_authFailedURL)
    End If
    %>
    <!--#include file="../../Connections/connInfologg.asp" -->
    <!--#include file="../../ScriptLibrary/incPureUpload.asp" -->
    <%
    '*** Pure ASP File Upload 2.1.9
    Dim GP_uploadAction,UploadQueryString
    PureUploadSetup
    If (CStr(Request.QueryString("GP_upload")) <> "") Then
    Dim
    pau_thePath,pau_Extensions,pau_Form,pau_Redirect,p au_storeType,pau_sizeLimit,pau
    _nameConflict,pau_requireUpload,pau_minWidth,pau_m inHeight,pau_maxWidth,pau_maxH
    eight,pau_saveWidth,pau_saveHeight,pau_timeout,pau _progressBar,pau_progressWidth
    ,pau_progressHeight
    pau_thePath = """../../bilder"""
    pau_Extensions = "GIF,JPG,JPEG,BMP,PNG"
    pau_Form = "form1"
    pau_Redirect = "Informasjon_ok.asp"
    pau_storeType = "file"
    pau_sizeLimit = ""
    pau_nameConflict = "over"
    pau_requireUpload = "false"
    pau_minWidth = ""
    pau_minHeight = ""
    pau_maxWidth = ""
    pau_maxHeight = ""
    pau_saveWidth = ""
    pau_saveHeight = ""
    pau_timeout = "600"
    pau_progressBar = ""
    pau_progressWidth = "300"
    pau_progressHeight = "100"

    Dim RequestBin, UploadRequest
    CheckPureUploadVersion 2.19
    ProcessUpload
    pau_thePath,pau_Extensions,pau_Redirect,pau_storeT ype,pau_sizeLimit,pau_nameConf
    lict,pau_requireUpload,pau_minWidth,pau_minHeight, pau_maxWidth,pau_maxHeight,pau
    _saveWidth,pau_saveHeight,pau_timeout
    end if
    %>
    <%
    ' *** Edit Operations: (Modified for File Upload) declare variables

    Dim MM_editAction
    Dim MM_abortEdit
    Dim MM_editQuery
    Dim MM_editCmd

    Dim MM_editConnection
    Dim MM_editTable
    Dim MM_editRedirectUrl
    Dim MM_editColumn
    Dim MM_recordId

    Dim MM_fieldsStr
    Dim MM_columnsStr
    Dim MM_fields
    Dim MM_columns
    Dim MM_typeArray
    Dim MM_formVal
    Dim MM_delim
    Dim MM_altVal
    Dim MM_emptyVal
    Dim MM_i

    MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
    If (UploadQueryString <> "") Then
    MM_editAction = MM_editAction & "?" & Server.HTMLEncode(UploadQueryString)
    End If

    ' boolean to abort record edit
    MM_abortEdit = false

    ' query string to execute
    MM_editQuery = ""
    %>
    <%
    ' *** Insert Record: (Modified for File Upload) set variables

    If (CStr(UploadFormRequest("MM_insert")) = "form1") Then

    MM_editConnection = MM_connInfologg_STRING
    MM_editTable = "informasjon"
    MM_editRedirectUrl = "Informasjon_ok.asp"
    MM_fieldsStr =
    "select|value|informasjonsOverskrift|value|informa sjonsBeskrivelse|value|file|va
    lue"
    MM_columnsStr =
    "informasjonsKategori|',none,''|informasjonsOversk rift|',none,''|informasjonsBes
    krivelse|',none,''|informasjonsBilde|',none,''"

    ' create the MM_fields and MM_columns arrays
    MM_fields = Split(MM_fieldsStr, "|")
    MM_columns = Split(MM_columnsStr, "|")

    ' set the form values
    For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
    MM_fields(MM_i+1) = CStr(UploadFormRequest(MM_fields(MM_i)))
    Next

    ' append the query string to the redirect URL
    If (MM_editRedirectUrl <> "" And UploadQueryString <> "") Then
    If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And
    UploadQueryString <> "") Then
    MM_editRedirectUrl = MM_editRedirectUrl & "?" & UploadQueryString
    Else
    MM_editRedirectUrl = MM_editRedirectUrl & "&" & UploadQueryString
    End If
    End If

    End If
    %>
    <%
    ' *** Insert Record: (Modified for File Upload) construct a sql insert
    statement and execute it

    Dim MM_tableValues
    Dim MM_dbValues

    If (CStr(UploadFormRequest("MM_insert")) <> "") Then

    ' create the sql insert statement
    MM_tableValues = ""
    MM_dbValues = ""
    For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
    MM_formVal = MM_fields(MM_i+1)
    MM_typeArray = Split(MM_columns(MM_i+1),",")
    MM_delim = MM_typeArray(0)
    If (MM_delim = "none") Then MM_delim = ""
    MM_altVal = MM_typeArray(1)
    If (MM_altVal = "none") Then MM_altVal = ""
    MM_emptyVal = MM_typeArray(2)
    If (MM_emptyVal = "none") Then MM_emptyVal = ""
    If (MM_formVal = "") Then
    MM_formVal = MM_emptyVal
    Else
    If (MM_altVal <> "") Then
    MM_formVal = MM_altVal
    ElseIf (MM_delim = "'") Then ' escape quotes
    MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
    Else
    MM_formVal = MM_delim + MM_formVal + MM_delim
    End If
    End If
    If (MM_i <> LBound(MM_fields)) Then
    MM_tableValues = MM_tableValues & ","
    MM_dbValues = MM_dbValues & ","
    End If
    MM_tableValues = MM_tableValues & MM_columns(MM_i)
    MM_dbValues = MM_dbValues & MM_formVal
    Next
    MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ")
    values (" & MM_dbValues & ")"

    If (Not MM_abortEdit) Then
    ' execute the insert
    Set MM_editCmd = Server.CreateObject("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_editConnection
    MM_editCmd.CommandText = MM_editQuery
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

    If (MM_editRedirectUrl <> "") Then
    Response.Redirect(MM_editRedirectUrl)
    End If
    End If

    End If
    %>
    <%
    Dim rsKategori
    Dim rsKategori_numRows

    Set rsKategori = Server.CreateObject("ADODB.Recordset")
    rsKategori.ActiveConnection = MM_connInfologg_STRING
    rsKategori.Source = "SELECT * FROM kategorier"
    rsKategori.CursorType = 0
    rsKategori.CursorLocation = 2
    rsKategori.LockType = 1
    rsKategori.Open()

    rsKategori_numRows = 0
    %>


    Sonic-x 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