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>
&lt;%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%&gt;
&lt;!--#include file="../Connections/News.asp" --&gt;
&lt;%
' *** 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 &lt;&gt; "" Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If

' boolean to abort record edit
MM_abortEdit = false

' query string to execute
MM_editQuery = ""
%&gt;
&lt;%
' *** Insert Record: set variables

If (CStr(Request("MM_insert") = "frmlaggtillny" Then

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 &lt;&gt; "" And Request.QueryString &lt;&gt; "" Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString &lt;&gt; "" Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If

End If
%&gt;
&lt;%
' *** Insert Record: construct a sql insert statement and execute it

Dim MM_tableValues
Dim MM_dbValues

If (CStr(Request("MM_insert") &lt;&gt; "" 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 &lt;&gt; "" 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 &lt;&gt; 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 &lt;&gt; "" Then
Response.Redirect(MM_editRedirectUrl)
End If
End If

End If
%&gt;
&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "www.w3.org/TR/html4/loose.dtd"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;
&lt;title&gt;Lägg till ny post för snabbmeddelanden&lt;/title&gt;
&lt;script type="text/javascript" language="javascript" src="../js/datetimepicker.js"&gt;&lt;/script&gt;
&lt;script language="JavaScript"&gt;
&lt;!--
if (document.images)
{
calimg= new Image(30,24);
calimg.src="../img/calender.gif";
}
//--&gt;
&lt;/script&gt;
&lt;link href="../css/udzone.css" rel="stylesheet" type="text/css"&gt;
&lt;style type="text/css"&gt;
&lt;!--
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}
--&gt;
&lt;/style&gt;

&lt;/head&gt;

&lt;body&gt;
&lt;span class="clsDetailNewsTitle style1 style2"&gt;L&auml;gg till ny post&lt;/span&gt;&lt;br&gt;
&lt;br&gt;
&lt;form ACTION="&lt;%=MM_editAction%&gt;" METHOD="POST" name="frmlaggtillny" id="frmlaggtillny"&gt;
&lt;table width="800" border="0" cellspacing="1" cellpadding="2"&gt;
&lt;tr&gt;
&lt;td colspan="4" class="style1"&gt;Rubrik:&lt;/td&gt;
&lt;td width="300" class="style1"&gt;Signatur:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="4"&gt;&lt;input name="rubrik" type="text" class="textrutor" id="rubrik" size="50"&gt;&lt;/td&gt;
&lt;td&gt;&lt;input name="signatur" type="text" class="textrutor" id="signatur" size="30"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="4" class="style1"&gt;Text:&lt;/td&gt;
&lt;td class="style1"&gt;L&auml;nk? (ej obligatoriskt):&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="4" rowspan="3" valign="top"&gt;&lt;textarea name="textmassa" cols="50" rows="4" class="textrutor" id="textmassa"&gt;&lt;/textarea&gt;&lt;/td&gt;
&lt;td valign="top"&gt;&lt;input name="links" type="text" class="textrutor" id="links" size="50"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" class="style1"&gt;Bild?: (Ej aktiv &auml;nnu) &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="2" class="style1"&gt;Visas fr&aring;n och med: &lt;/td&gt;
&lt;td colspan="2" class="style1"&gt;Visas till och med: &lt;/td&gt;
&lt;td class="style1"&gt;&nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td width="148"&gt;&lt;input name="giltigfran" type="text" class="textrutor"&gt;&lt;/td&gt;
&lt;td width="49"&gt;&lt;a href="javascript:NewCal('giltigfran','yyyymmdd')"&gt;&lt;img src="../img/calender.gif" width="30" height="24" border="0" alt="Välj datum (Visas från och med)"&gt;&lt;/a&gt;&lt;/td&gt;
&lt;td width="149"&gt;&lt;input name="giltigtill" type="text" class="textrutor"&gt;&lt;/td&gt;
&lt;td width="128"&gt;&lt;a href="javascript:NewCal('giltigtill','yyyymmdd')"&gt;&lt;img src="../img/calender.gif" width="30" height="24" border="0" alt="Välj datum (Visas till och med)"&gt;&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="4"&gt;&nbsp;&lt;/td&gt;
&lt;td&gt;&nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="4"&gt;&lt;input type="submit" name="Submit" value="Lägg till"&gt;&lt;/td&gt;
&lt;td&gt;&lt;input type="reset" name="Reset" value="Rensa fält"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="4"&gt;&nbsp;&lt;/td&gt;
&lt;td&gt;&nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="4"&gt;&lt;/td&gt;
&lt;td&gt;&nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;





&lt;input type="hidden" name="MM_insert" value="frmlaggtillny"&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;

</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
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
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.

Reply to this topic