Click to See Complete Forum and Search --> : Need help completing a forum with ASP


jonthomas83
04-14-2007, 04:51 AM
Hi guys I've done everything apart from the final hurdle with a forum that I've been working on.

I keep getting the following error message:

Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.

/02014092/lightsynth/forum_add_reply.asp, line 115


I'm trying to post a reply to a thread that is stored in one table and the reply will be stored in a new table.

I'm using the insert new record function with ASP but nothing seems to work.

Here's the code!

<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/MyRepliesConnection.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 & "?" & 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")) = "form2") Then

MM_editConnection = MM_MyRepliesConnection_STRING
MM_editTable = "reply"
MM_editRedirectUrl = "forum_replied_successfully.asp"
MM_fieldsStr = "MyTopicReply|value|MyUsernameReply|value|MyPostReply|value"
MM_columnsStr = "MyTopicReply|',none,''|MyUsernameReply|',none,''|MyPostReply|',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
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="nav.js"></script>

<body>
<%
Response.Expires = -1000 'Makes the browser not cache this page
Response.Buffer = True 'Buffers the content so our Response.Redirect will work

If Session("UserLoggedIn") <> "true" Then
Response.Redirect("login.asp")
End If
%>

<div class="main">
<img src="images/logo.png" alt="Lightsynth" width="619" height="86" />
<div id="globalNav">
<div id="globalLink"><a href="index.html" id="gl1" class="glink" onMouseOver="ehandler(event,menuitem1);">Home</a><a href="http://lightsynth.blogspot.com/" id="gl2" class="glink" onMouseOver="ehandler(event,menuitem2);" target="_blank">Blog</a><a href="history.html" id="gl3" class="glink" onMouseOver="ehandler(event,menuitem3);">History</a><a href="products.html" id="gl4" class="glink" onMouseOver="ehandler(event,menuitem4);">Products</a><a href="downloads.html" id="gl5" class="glink" onMouseOver="ehandler(event,menuitem5);">Downloads</a><a href="contact_us.html" id="gl6" class="glink" onMouseOver="ehandler(event,menuitem6);">Contact Us</a><a href="members_home.asp" id="gl7" class="glink" onMouseOver="ehandler(event,menuitem7);">Members</a><a href="links.html" id="gl8" class="glink" onMouseOver="ehandler(event,menuitem8);">Links</a></div>
<!-- end globalNav -->
<div id="subglobal1" class="subglobalNav"> </div>
<div id="subglobal2" class="subglobalNav"> </div>
<div id="subglobal3" class="subglobalNav"> <a href="making_of.html">Making The Lightsynth</a> | <a href="video_diary.html">Video Diary</a></div>
<div id="subglobal4" class="subglobalNav"> <a href="products.html">About Our Products</a> | <a href="audio.html">Audio Demo's</a> | <a href="video.html">Video Demo's</a></div>
<div id="subglobal5" class="subglobalNav"> <a href="vst.html">VST Upgrades</a> | <a href="firmware.html">Firmware Upgrades</a> | <a href="manuals.html">Manuals</a> | <a href="members_tunes.asp">Members Tunes</a>
</div>
<div id="subglobal6" class="subglobalNav"></div>
<div id="subglobal7" class="subglobalNav"><a href="view_all_members.asp">View All Members</a> | <a href="update_account.asp">Update Personal Account</a> | <a href="forum.asp">Members Forum</a></div>
<div id="subglobal8" class="subglobalNav"></div>
<script type="text/javascript" src="hidden.js"></script>
</div>
<div class="content"><h1><img src="images/members_forum_pic.gif" alt="Members Forum" /></h1>

<div class="login_info"><p>Logged in as: <a href="members_home.asp"><span class="user"><%Response.Write (Request.Cookies("DisplayName")) %></span></a> | <a href="logout.asp">Logout</a></p>
</div>
<p>Add Reply to Topic - </p>
<form method="POST" action="<%=MM_editAction%>" name="form2">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">Topic:</td>
<td><input type="hidden" name="MyTopicReply" value="<%=Request.QueryString("MyTopic")%>" size="32"><%=Request.QueryString("MyTopic")%>
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Username:</td>
<td><input type="hidden" name="MyUsernameReply" value="<%Response.Write (Request.Cookies("DisplayName")) %>" size="32"><%Response.Write (Request.Cookies("DisplayName")) %>
</td>
</tr>
<tr>
<td nowrap align="right" valign="top">Message:</td>
<td valign="baseline"><textarea name="MyPostReply" cols="50" rows="5"></textarea>
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">&nbsp;</td>
<td><input type="submit" value="Add Message">
</td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form2">
</form>
</div>
</div></body>
</html>

buntine
04-14-2007, 10:20 AM
Ok, this issue normally occurs when you do not have permissions set correctly. Are you using MS Access? If so, you need to allow the database file to create temporary lock files. This means the directory the database resides in needs full read and write permissions.

Otherwise, make sure the Connection Object allows writing. By default it should, but just to be sure, try this:

MM_editCmd.Mode = 3

Put that line just above the call to MM_editCmd.Execute.

Cheers,
Andrew Buntine.

jonthomas83
04-14-2007, 10:33 AM
Ok cheers, i'm not in uni to make canges to the permissions directly on the server at the moment and the SSH program (winscp) doesn't allow me to touch the permission sets on the databases I don't think anyway. Yeah I'm using MSAccess.

I've tried the code you suggested and the error is now saying:

Microsoft VBScript runtime error '800a01b6'

Object doesn't support this property or method: 'Mode'

/02014092/lightsynth/forum_add_reply.asp, line 115

buntine
04-14-2007, 08:36 PM
Try MM_editConnection.Mode = 3

Cheers,
Andrew Buntine

jonthomas83
04-15-2007, 06:20 AM
lol, this is a joke isn't it! I'm really sorry!

New error...

Microsoft VBScript runtime error '800a01a8'

Object required: 'DRIVER={Microsoft Ac'

/02014092/lightsynth/forum_add_reply.asp, line 115


Thanks again,
Jonathan

buntine
04-15-2007, 07:41 AM
It looks like there is an issue with your connection string. Perhaps you can give me a look, but make sure you edit out any compromising data (passwords, etc).

I am sure this is a very easy issue to rectify, but it may be hard without being there behind you giving instructions! heh

Cheers,
Andrew Buntine.

jonthomas83
04-15-2007, 08:05 AM
for this forum section I've set up two databases,

one called 'forum' and one called 'replies'

there are two connections, one for the part where a user creates a thread - inserted into the 'forum' database

<%
' FileName="Connection_ado_conn_string.htm"
' Type="ADO"
' DesigntimeType="ADO"
' HTTP="true"
' Catalog=""
' Schema=""
Dim MM_MyForumConnection_STRING
MM_MyForumConnection_STRING = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("/02014092/lightsynth/forum.mdb") & ";"
%>

and the other is where the replies get sent, which is what's not working and the part we've been working on...

<%
' FileName="Connection_ado_conn_string.htm"
' Type="ADO"
' DesigntimeType="ADO"
' HTTP="true"
' Catalog=""
' Schema=""
Dim MM_MyRepliesConnection_STRING
MM_MyRepliesConnection_STRING = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("/02014092/lightsynth/replies.mdb") & ";"
%>


hope that's what you need, if there's anything else, let me know and I'll get it posted for you.

Thanks so much again for all your efforts
Jonathan

jonthomas83
04-17-2007, 06:06 AM
Hi guys I'm getting this error when I try posting a reply to a self made forum, can anyone help me solve the problem? All the permissions are set so that the databases can be added to, just to get over the final hurdle now!

Microsoft VBScript runtime error '800a01a8'

Object required: 'DRIVER={Microsoft Ac'

/02014092/lightsynth/forum_add_reply.asp, line 115

<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/MyRepliesConnection.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 & "?" & 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")) = "form2") Then

MM_editConnection = MM_MyRepliesConnection_STRING
MM_editTable = "reply"
MM_editRedirectUrl = "forum_replied_successfully.asp"
MM_fieldsStr = "MyTopicReply|value|MyUsernameReply|value|MyPostReply|value"
MM_columnsStr = "MyTopicReply|',none,''|MyUsernameReply|',none,''|MyPostReply|',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_editConnection.Mode = 3
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close

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

End If
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="nav.js"></script>

<body>
<%
Response.Expires = -1000 'Makes the browser not cache this page
Response.Buffer = True 'Buffers the content so our Response.Redirect will work

If Session("UserLoggedIn") <> "true" Then
Response.Redirect("login.asp")
End If
%>

<div class="main">
<img src="images/logo.png" alt="Lightsynth" width="619" height="86" />
<div id="globalNav">
<div id="globalLink"><a href="index.html" id="gl1" class="glink" onMouseOver="ehandler(event,menuitem1);">Home</a><a href="http://lightsynth.blogspot.com/" id="gl2" class="glink" onMouseOver="ehandler(event,menuitem2);" target="_blank">Blog</a><a href="history.html" id="gl3" class="glink" onMouseOver="ehandler(event,menuitem3);">History</a><a href="products.html" id="gl4" class="glink" onMouseOver="ehandler(event,menuitem4);">Products</a><a href="downloads.html" id="gl5" class="glink" onMouseOver="ehandler(event,menuitem5);">Downloads</a><a href="contact_us.html" id="gl6" class="glink" onMouseOver="ehandler(event,menuitem6);">Contact Us</a><a href="members_home.asp" id="gl7" class="glink" onMouseOver="ehandler(event,menuitem7);">Members</a><a href="links.html" id="gl8" class="glink" onMouseOver="ehandler(event,menuitem8);">Links</a></div>
<!-- end globalNav -->
<div id="subglobal1" class="subglobalNav"> </div>
<div id="subglobal2" class="subglobalNav"> </div>
<div id="subglobal3" class="subglobalNav"> <a href="making_of.html">Making The Lightsynth</a> | <a href="video_diary.html">Video Diary</a></div>
<div id="subglobal4" class="subglobalNav"> <a href="products.html">About Our Products</a> | <a href="audio.html">Audio Demo's</a> | <a href="video.html">Video Demo's</a></div>
<div id="subglobal5" class="subglobalNav"> <a href="vst.html">VST Upgrades</a> | <a href="firmware.html">Firmware Upgrades</a> | <a href="manuals.html">Manuals</a> | <a href="members_tunes.asp">Members Tunes</a>
</div>
<div id="subglobal6" class="subglobalNav"></div>
<div id="subglobal7" class="subglobalNav"><a href="view_all_members.asp">View All Members</a> | <a href="update_account.asp">Update Personal Account</a> | <a href="forum.asp">Members Forum</a></div>
<div id="subglobal8" class="subglobalNav"></div>
<script type="text/javascript" src="hidden.js"></script>
</div>
<div class="content"><h1><img src="images/members_forum_pic.gif" alt="Members Forum" /></h1>

<div class="login_info"><p>Logged in as: <a href="members_home.asp"><span class="user"><%Response.Write (Request.Cookies("DisplayName")) %></span></a> | <a href="logout.asp">Logout</a></p>
</div>
<p>Add Reply to Topic - </p>
<form method="POST" action="<%=MM_editAction%>" name="form2">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">Topic:</td>
<td><input type="hidden" name="MyTopicReply" value="<%=Request.QueryString("MyTopic")%>" size="32"><%=Request.QueryString("MyTopic")%>
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Username:</td>
<td><input type="hidden" name="MyUsernameReply" value="<%Response.Write (Request.Cookies("DisplayName")) %>" size="32"><%Response.Write (Request.Cookies("DisplayName")) %>
</td>
</tr>
<tr>
<td nowrap align="right" valign="top">Message:</td>
<td valign="baseline"><textarea name="MyPostReply" cols="50" rows="5"></textarea>
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">&nbsp;</td>
<td><input type="submit" value="Add Message">
</td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form2">
</form>
</div>
</div></body>
</html>

Please help

Many thanks,
Jonathan