PDA

View Full Version : Hard problem with update record. Help me please!!


renixx
03-23-2009, 02:00 PM
Hi to all friends,
Mi huge problem is:
- I've created an update page with asp+access+Dreamweaver
- I've created also a confirmation page
I've setted my record as MEMO field.

My connection string: MM_prezzi_STRING ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("/mdb-database/prezzi.mdb")
If, instead, i try to use a classic dns-less: MM_prezzi_STRING = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("/mdb-database/prezzi.mdb") it show me an error:ODBC Microsoft Access Driver]Invalid precision value.

Now, I can modify data as first time, but if I try to re-modify (re-update) again after few seconds, nothing are updated! is similar as if database is asleep!

My coded used:

--------------------------------------------------
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="../Connections/prezzi.asp" -->
<%
Dim MM_editAction
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
Dim MM_abortEdit
MM_abortEdit = false
%>
<%
If (CStr(Request("MM_update")) = "form1") Then
If (Not MM_abortEdit) Then
' execute the update
Dim MM_editCmd

Set MM_editCmd = Server.CreateObject ("ADODB.Command")
MM_editCmd.ActiveConnection = MM_prezzi_STRING
MM_editCmd.CommandText = "UPDATE prezzi SET prezzi = ? WHERE prezzi = ?"
MM_editCmd.Prepared = true
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 203,
1, 1073741823, Request.Form("prezzi")) ' adLongVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 200,
1, 1073741823, Request.Form("MM_recordId")) ' adVarChar
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close

' append the query string to the redirect URL
Dim MM_editRedirectUrl
MM_editRedirectUrl = "ok_price.asp"
If (Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
Response.Redirect(MM_editRedirectUrl)
End If
End If
%>
<%
Dim rs_prezzi
Dim rs_prezzi_cmd
Dim rs_prezzi_numRows

Set rs_prezzi_cmd = Server.CreateObject ("ADODB.Command")
rs_prezzi_cmd.ActiveConnection = MM_prezzi_STRING
rs_prezzi_cmd.CommandText = "SELECT prezzi FROM prezzi"
rs_prezzi_cmd.Prepared = true

Set rs_prezzi = rs_prezzi_cmd.Execute
rs_prezzi_numRows = 0
%>
<html>
<head></head>
<body>
<form action="<%=MM_editAction%>" method="post" name="form1" id="form1">
<table align="center">
<tr>
<td nowrap="nowrap" align="right" valign="top"></td>
<td valign="baseline"><textarea name="prezzi" cols="50"
rows="5"><%=(rs_prezzi.Fields.Item("prezzi").Value)%></textarea>
</td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value="Aggiorna record" />
</td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1" />
<input type="hidden" name="MM_recordId" value="<%=
rs_prezzi.Fields.Item("prezzi").Value %>" />
</form>

</body></html>
<%
rs_prezzi.Close()
Set rs_prezzi = Nothing
%>



For me is very important to solve it as soon as possible.
Thanks a lot FRIENDS!!

Old Pedant
03-23-2009, 08:47 PM
I think it's just a case of bad database design.

How many records are IN your prezzi TABLE???

It *feels* like you only have ONE record. Is that true??

shakir
03-29-2009, 03:43 PM
may be connection string problem
Conn="Provider=Microsoft.Jet.OLEDB.4.0;User ID=;Password=;Data Source=" & server.mappath("/mdb-database/prezzi.mdb")
its working fine with me