Forums
This topic is locked
Help, i cant insert anything to my db.....
Posted 12 May 2005 11:14:34
1
has voted
12 May 2005 11:14:34 Henrik Sandeberg posted:
I have an Windows 2000 Server with IIS and Access as db, icant insert any data to the db, i always getting this....Im using a DSN connection on the server cause i cant get a connection string to work properly in Dreamweaver
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.
/portal/menu/new.asp, line 115
The page:
<pre id=code><font face=courier size=2 id=code>
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/News.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 <> ""

MM_editAction = MM_editAction & "?" & Server.HTMLEncode(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"


MM_editConnection = MM_News_STRING
MM_editTable = "News"
MM_editRedirectUrl = "main.asp"
MM_fieldsStr = "rubrik|value|signatur|value|textmassa|value|links|value|giltigfran|value|giltigtill|value"
MM_columnsStr = "rubrik|',none,''|signatur|',none,''|huvudtext|',none,''|lank|',none,''|franochmed|',none,NULL|tillochmed|',none,NULL"
' 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 <> ""

If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> ""

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"


' 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"

MM_altVal = MM_typeArray(1)
If (MM_altVal = "none"

MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none"

If (MM_formVal = ""

MM_formVal = MM_emptyVal
Else
If (MM_altVal <> ""

MM_formVal = MM_altVal
ElseIf (MM_delim = "'"

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 & "


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 <> ""

Response.Redirect(MM_editRedirectUrl)
End If
End If
End If
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Lägg till ny post för snabbmeddelanden</title>
<script type="text/javascript" language="javascript" src="../js/datetimepicker.js"></script>
<script language="JavaScript">
<!--
if (document.images)
{
calimg= new Image(30,24);
calimg.src="../img/calender.gif";
}
//-->
</script>
<link href="../css/udzone.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
background-color: #47637A;
margin-left: 5px;
margin-top: 4px;
}
.textrutor {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
border: 1px solid #006699;
background-color: #FFFFFF;
color: #000000;
}
input {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #FFFFFF;
background-color: #6D90AA;
border: 1px solid #003399;
}
.style1 {color: #FFFFFF}
.style2 {font-size: medium}
-->
</style>
</head>
<body>
<span class="clsDetailNewsTitle style1 style2">Lägg till ny post</span><br>
<br>
<form ACTION="<%=MM_editAction%>" METHOD="POST" name="frmlaggtillny" id="frmlaggtillny">
<table width="800" border="0" cellspacing="1" cellpadding="2">
<tr>
<td colspan="4" class="style1">Rubrik:</td>
<td width="300" class="style1">Signatur:</td>
</tr>
<tr>
<td colspan="4"><input name="rubrik" type="text" class="textrutor" id="rubrik" size="50"></td>
<td><input name="signatur" type="text" class="textrutor" id="signatur" size="30"></td>
</tr>
<tr>
<td colspan="4" class="style1">Text:</td>
<td class="style1">Länk? (ej obligatoriskt):</td>
</tr>
<tr>
<td colspan="4" rowspan="3" valign="top"><textarea name="textmassa" cols="50" rows="4" class="textrutor" id="textmassa"></textarea></td>
<td valign="top"><input name="links" type="text" class="textrutor" id="links" size="50"></td>
</tr>
<tr>
<td valign="top" class="style1">Bild?: (Ej aktiv ännu) </td>
</tr>
<tr>
<td valign="top"> </td>
</tr>
<tr>
<td colspan="2" class="style1">Visas från och med: </td>
<td colspan="2" class="style1">Visas till och med: </td>
<td class="style1"> </td>
</tr>
<tr>
<td width="148"><input name="giltigfran" type="text" class="textrutor"></td>
<td width="49"><a href="javascript:NewCal('giltigfran','yyyymmdd')"><img src="../img/calender.gif" width="30" height="24" border="0" alt="Välj datum (Visas från och med)"></a></td>
<td width="149"><input name="giltigtill" type="text" class="textrutor"></td>
<td width="128"><a href="javascript:NewCal('giltigtill','yyyymmdd')"><img src="../img/calender.gif" width="30" height="24" border="0" alt="Välj datum (Visas till och med)"></a></td>
<td> </td>
</tr>
<tr>
<td colspan="4"> </td>
<td> </td>
</tr>
<tr>
<td colspan="4"><input type="submit" name="Submit" value="Lägg till"></td>
<td><input type="reset" name="Reset" value="Rensa fält"></td>
</tr>
<tr>
<td colspan="4"> </td>
<td> </td>
</tr>
<tr>
<td colspan="4"></td>
<td> </td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="frmlaggtillny">
</form>
</body>
</html>
</font id=code></pre id=code>
The DSN:
' FileName="Connection_odbc_conn_dsn.htm"
' Type="ADO"
' DesigntimeType="ADO"
' HTTP="true"
' Catalog=""
' Schema=""
Dim MM_News_STRING
MM_News_STRING = "dsn=port;"
Anyone?
Replies
Replied 12 May 2005 11:58:29
12 May 2005 11:58:29 Simon Bloodworth replied:
Hi
Check the permissions on your database - make sure that it allows read/write operations.
regards
Simon
DWMX 2004 | ASP | VBScript
Check the permissions on your database - make sure that it allows read/write operations.
regards
Simon
DWMX 2004 | ASP | VBScript
Replied 12 May 2005 12:13:30
12 May 2005 12:13:30 Henrik Sandeberg replied:
Ok, just on the catalog or what? in IIS?
/Henrik
/Henrik
Replied 12 May 2005 12:25:39
12 May 2005 12:25:39 Henrik Sandeberg replied:
Ok, tried to change for users to write in the db directory, and whops, there it goes......
Thanks for the help, cause my brain was shut off.
Thanks for the help, cause my brain was shut off.