|
 |
access_asp thread: Can't write to database
Message #1 by "vinny199" <vinny199@l...> on Wed, 4 Sep 2002 10:44:20
|
|
Hi,
Please help me if you can as everything I have tried has failed and I ran
out of ideas:
I can view the database no problem but can't write/update it.
I always get the following error:
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
Operation must use an updateable query.
This error suggests permission issues, but both read/write permissions
are given in access2000 for my database and in IIS.
No userid/paswords have been set.
I connect to the database using an OLEDB connection.
I have created the virtual directory in IIS.
All is fine but no writing to the database!!
I have used recordsets to update the database.
There are two recordsets, the first one is to view the database, the
second one to insert data.
i am learning how to use Dreamweaver MX which (I don't know if you are
familiar with) makes the connection string as a file and calls it up in
the page.
So for: <!--#include file="Connections/conn_webprodmx.asp" --> please
read:"Provider=Microsoft.Jet.OLEDB.4.0;DataSource=c:\webprodmx_files\webpr
odmx_data.mdb;"
Here is the code .
Thanks you,
Vinny
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/conn_webprodmx.asp" -->
<%
' *** Edit Operations: 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 (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Request.QueryString
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
' *** Insert Record: set variables
If (CStr(Request("MM_insert")) = "form1") Then
MM_editConnection = MM_conn_webprodmx_STRING
MM_editTable = "categories"
MM_editRedirectUrl = "categories3.asp"
MM_fieldsStr = "category|value"
MM_columnsStr = "category|',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(Request.Form(MM_fields(MM_i)))
Next
' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And
Request.QueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
End If
%>
<%
' *** Insert Record: construct a sql insert statement and execute it
Dim MM_tableValues
Dim MM_dbValues
If (CStr(Request("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 rsCategories
Dim rsCategories_numRows
Set rsCategories = Server.CreateObject("ADODB.Recordset")
rsCategories.ActiveConnection = MM_conn_webprodmx_STRING
rsCategories.Source = "SELECT * FROM categories ORDER BY category_id ASC"
rsCategories.CursorType = 0
rsCategories.CursorLocation = 2
rsCategories.LockType = 1
rsCategories.Open()
rsCategories_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = -1
Repeat1__index = 0
rsCategories_numRows = rsCategories_numRows + Repeat1__numRows
%>
<%
Dim MM_paramName
%>
<%
' *** Go To Record and Move To Record: create strings for maintaining URL
and Form parameters
Dim MM_keepNone
Dim MM_keepURL
Dim MM_keepForm
Dim MM_keepBoth
Dim MM_removeList
Dim MM_item
Dim MM_nextItem
' create the list of parameters which should not be maintained
MM_removeList = "&index="
If (MM_paramName <> "") Then
MM_removeList = MM_removeList & "&" & MM_paramName & "="
End If
MM_keepURL=""
MM_keepForm=""
MM_keepBoth=""
MM_keepNone=""
' add the URL parameters to the MM_keepURL string
For Each MM_item In Request.QueryString
MM_nextItem = "&" & MM_item & "="
If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
MM_keepURL = MM_keepURL & MM_nextItem & Server.URLencode
(Request.QueryString(MM_item))
End If
Next
' add the Form variables to the MM_keepForm string
For Each MM_item In Request.Form
MM_nextItem = "&" & MM_item & "="
If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
MM_keepForm = MM_keepForm & MM_nextItem & Server.URLencode
(Request.Form(MM_item))
End If
Next
' create the Form + URL string and remove the intial '&' from each of the
strings
MM_keepBoth = MM_keepURL & MM_keepForm
If (MM_keepBoth <> "") Then
MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)
End If
If (MM_keepURL <> "") Then
MM_keepURL = Right(MM_keepURL, Len(MM_keepURL) - 1)
End If
If (MM_keepForm <> "") Then
MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)
End If
' a utility function used for adding additional parameters to these
strings
Function MM_joinChar(firstItem)
If (firstItem <> "") Then
MM_joinChar = "&"
Else
MM_joinChar = ""
End If
End Function
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<table border="1">
<tr>
<td>category_id</td>
<td>category</td>
</tr>
<% While ((Repeat1__numRows <> 0) AND (NOT rsCategories.EOF)) %>
<tr>
<td><%=(rsCategories.Fields.Item("category_id").Value)%></td>
<td><A HREF="book.asp?<%= MM_keepNone & MM_joinChar(MM_keepNone)
& "category_id=" & rsCategories.Fields.Item("category_id").Value %>"><%
(rsCategories.Fields.Item("category").Value)%></A></td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rsCategories.MoveNext()
Wend
%>
</table>
<hr />
<p> </p>
<form name="form1" id="form1" method="POST" action="<%=MM_editAction%>">
<table width="50%" border="1">
<tr>
<td>Category</td>
<td> <input name="category" type="text" id="category" /></td>
</tr>
<tr>
<td> </td>
<td> <input type="submit" name="Submit" value="Insert
Category" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>
<p> </p>
<p> </p>
</body>
</html>
<%
rsCategories.Close()
Set rsCategories = Nothing
%>
Message #2 by pagol sagol <sagolbd@y...> on Wed, 4 Sep 2002 03:59:31 -0700 (PDT)
|
|
Hi,
I have understood your problem.You have to give
permission on your web folder.To do that In your root
directory thats mean at C: drive choose
inetpub\wwwroot\(your working folder).Then click
button of your mouse and choose properties and then
security at security option give read and write
permission to Everyone and internetuser.Then your
problem will be solved.If problem is solved please let
me know.
Salahuddin Ahmed
__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com
Message #3 by "Ostrander, Lewis" <OstranderL@M...> on Wed, 4 Sep 2002 08:25:44 -0400
|
|
Which person in this group has an email virus? I am getting a spam every
2-3 minutes. Subject heading is Please Try Again or Spice Girls
The exe file is Suzanne and scr.
Please check and let everyone know.
Thanks.
Lewis
-----Original Message-----
From: pagol sagol [mailto:sagolbd@y...]
Sent: Wednesday, September 04, 2002 7:00 AM
To: Access ASP
Subject: [access_asp] Re: Can't write to database
Hi,
I have understood your problem.You have to give
permission on your web folder.To do that In your root
directory thats mean at C: drive choose
inetpub\wwwroot\(your working folder).Then click
button of your mouse and choose properties and then
security at security option give read and write
permission to Everyone and internetuser.Then your
problem will be solved.If problem is solved please let
me know.
Salahuddin Ahmed
__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com
Message #4 by "vinny199" <vinny199@l...> on Wed, 4 Sep 2002 17:14:52
|
|
Thanks Salahuddin Ahmed,
The problem was that I could not get to the security tab you mention. I
had to uncheck share single files to get that tab to appear (WinXP).
I have now given the permissions you suggest and it works!!
Cheers,
Vinny
__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com
|
|
 |