|
| problem i update form Fra : Jens |
Dato : 06-02-04 09:02 |
|
Jeg har et mærkeligt problem i en update-formular, som jeg har levet. Jeg
opdaterer en persontabel i Access, men når jeg forsøger at eksekvere
opdateringen, kommer den med følgende fejl:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE
statement.
/person-detalje.asp, line 111
Jeg har før lavet hundreder af update-formularer, men denne her kan jeg ikke
greje.
Der er i linje 111, den stopper og der står:
MM_editCmd.Execute
Jeg har hele filen nedenfor.
Jeg er desperat for at finde en løsning....
/Rudy
----
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/pegasusDB.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 = ""
%>
<%
' *** Update Record: set variables
If (CStr(Request("MM_update")) = "form1" And CStr(Request("MM_recordId")) <>
"") Then
MM_editConnection = MM_pegasusDB_STRING
MM_editTable = "tPerson"
MM_editColumn = "PersonID"
MM_recordId = "" + Request.Form("MM_recordId") + ""
MM_editRedirectUrl = ""
MM_fieldsStr = "PersonID|value|Navn|value|Telefon|value|Email|value"
MM_columnsStr =
"PersonID|none,none,NULL|Navn|',none,''|Telefon|',none,''|E-mail|',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
%>
<%
' *** Update Record: construct a sql update statement and execute it
If (CStr(Request("MM_update")) <> "" And CStr(Request("MM_recordId")) <> "")
Then
' create the sql update statement
MM_editQuery = "update " & MM_editTable & " set "
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_editQuery = MM_editQuery & ","
End If
MM_editQuery = MM_editQuery & MM_columns(MM_i) & " = " & MM_formVal
Next
MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " &
MM_recordId
If (Not MM_abortEdit) Then
' execute the update
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 personer__MMColParam
personer__MMColParam = "1"
If (Request.QueryString("PersonID") <> "") Then
personer__MMColParam = Request.QueryString("PersonID")
End If
%>
<%
Dim personer
Dim personer_numRows
Set personer = Server.CreateObject("ADODB.Recordset")
personer.ActiveConnection = MM_pegasusDB_STRING
personer.Source = "SELECT * FROM tPerson WHERE PersonID = " +
Replace(personer__MMColParam, "'", "''") + ""
personer.CursorType = 0
personer.CursorLocation = 2
personer.LockType = 3
personer.Open()
personer_numRows = 0
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="styles.css" rel="stylesheet" type="text/css">
</head>
<body background="grafik/baggrund-right.gif" bgproperties="fixed"
leftmargin="20">
<table width="573" border="0">
<tr>
<td><p align="right" class="overskrifter">Personer</p></td>
</tr>
</table>
<br>
<br>
<p> </p>
<form method="post" action="<%=MM_editAction%>" name="form1">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">PersonID:</td>
<td> <input type="text" name="PersonID"
value="<%=(personer.Fields.Item("PersonID").Value)%>" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Navn:</td>
<td> <input type="text" name="Navn"
value="<%=(personer.Fields.Item("Navn").Value)%>" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Telefon:</td>
<td> <input type="text" name="Telefon"
value="<%=(personer.Fields.Item("Telefon").Value)%>" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">E-mail:</td>
<td> <input type="text" name="Email"
value="<%=(personer.Fields.Item("E-mail").Value)%>" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td> <input type="submit" value="Update Record"> </td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1">
<input type="hidden" name="MM_recordId" value="<%=
personer.Fields.Item("PersonID").Value %>">
</form>
<p> </p>
<p> </p>
<p> </p>
<table align="center" border="1">
<tr>
<td align="default" width="50%">PersonID</td>
<td align="default"
width="50%"><%=(personer.Fields.Item("PersonID").Value)%></td>
</tr>
<tr>
<td align="default" width="50%">Navn</td>
<td align="default"
width="50%"><%=(personer.Fields.Item("Navn").Value)%></td>
</tr>
<tr>
<td align="default" width="50%">Telefon</td>
<td align="default"
width="50%"><%=(personer.Fields.Item("Telefon").Value)%></td>
</tr>
<tr>
<td align="default" width="50%">E-mail</td>
<td align="default"
width="50%"><%=(personer.Fields.Item("E-mail").Value)%></td>
</tr>
</table></body>
</html>
<%
personer.Close()
Set personer = Nothing
%>
| |
Lars Olesen (06-02-2004)
| Kommentar Fra : Lars Olesen |
Dato : 06-02-04 09:18 |
| | |
Jørgen Müller (06-02-2004)
| Kommentar Fra : Jørgen Müller |
Dato : 06-02-04 09:27 |
|
Jens skrev
>Jeg har et mærkeligt problem i en update-formular, som jeg har levet. Jeg
>opdaterer en persontabel i Access, men når jeg forsøger at eksekvere
>opdateringen, kommer den med følgende fejl:
>
> Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
>
> [Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE
>statement.
>
> /person-detalje.asp, line 111
Udskriv din sql streng. Hvis du så ikke selv kan se fejlen, så bør du nok
poste den i dk.edb.internet.webdesign.serverside.asp hvor sådan et spørgsmål
hører hjemme.
Det er svært at gætte sig til hvor linie 111 er, havde været noget nemmere
hvis du kun havde vist relevant kode?
Har vist dig hvordan du udskriver din streng længere nede i koden.
> ' create the sql update statement
> MM_editQuery = "update " & MM_editTable & " set "
> 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_editQuery = MM_editQuery & ","
> End If
> MM_editQuery = MM_editQuery & MM_columns(MM_i) & " = " & MM_formVal
> Next
> MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " &
>MM_recordId
response.write MM_editQuery
response.end
> If (Not MM_abortEdit) Then
> ' execute the update
> Set MM_editCmd = Server.CreateObject("ADODB.Command")
> MM_editCmd.ActiveConnection = MM_editConnection
> MM_editCmd.CommandText = MM_editQuery
'Dette er linie 111? > MM_editCmd.Execute
> MM_editCmd.ActiveConnection.Close
--
Med Venlig Hilsen
Jørgen Müller
| |
Rudy Madsen (06-02-2004)
| Kommentar Fra : Rudy Madsen |
Dato : 06-02-04 09:54 |
|
Hej Jørgen
Du har gættet rigtigt med hensyn til hvor linje 111 er. Det mærkelige er, at
jeg har i samme webside og i samme database, lavet en updateform, der
opdaterer en anden tabel, - altså på nøjagtig samme måde, og der er
principielt ingen forskel på koden i de to filer. Den ene virker - men den
anden gør ikke?
Hvis det er et serverside problem, ved du så noget om det?
/Rudy (som før var jens)
"Jørgen Müller" <j.muller@mail.tele.dk> skrev i en meddelelse
news:bvvj4n$bts$1@sunsite.dk...
> Jens skrev
> >Jeg har et mærkeligt problem i en update-formular, som jeg har levet. Jeg
> >opdaterer en persontabel i Access, men når jeg forsøger at eksekvere
> >opdateringen, kommer den med følgende fejl:
> >
> > Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
> >
> > [Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE
> >statement.
> >
> > /person-detalje.asp, line 111
>
> Udskriv din sql streng. Hvis du så ikke selv kan se fejlen, så bør du nok
> poste den i dk.edb.internet.webdesign.serverside.asp hvor sådan et
spørgsmål
> hører hjemme.
>
> Det er svært at gætte sig til hvor linie 111 er, havde været noget nemmere
> hvis du kun havde vist relevant kode?
> Har vist dig hvordan du udskriver din streng længere nede i koden.
> > ' create the sql update statement
> > MM_editQuery = "update " & MM_editTable & " set "
> > 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_editQuery = MM_editQuery & ","
> > End If
> > MM_editQuery = MM_editQuery & MM_columns(MM_i) & " = " & MM_formVal
> > Next
> > MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " &
> >MM_recordId
>
> response.write MM_editQuery
> response.end
>
> > If (Not MM_abortEdit) Then
> > ' execute the update
> > Set MM_editCmd = Server.CreateObject("ADODB.Command")
> > MM_editCmd.ActiveConnection = MM_editConnection
> > MM_editCmd.CommandText = MM_editQuery
> 'Dette er linie 111? > MM_editCmd.Execute
> > MM_editCmd.ActiveConnection.Close
>
> --
> Med Venlig Hilsen
> Jørgen Müller
>
>
| |
Jens Gyldenkærne Cla~ (06-02-2004)
| Kommentar Fra : Jens Gyldenkærne Cla~ |
Dato : 06-02-04 11:32 |
|
Rudy Madsen skrev:
> Du har gættet rigtigt med hensyn til hvor linje 111 er. Det
> mærkelige er, at jeg har i samme webside og i samme database,
> lavet en updateform, der opdaterer en anden tabel, - altså på
> nøjagtig samme måde, og der er principielt ingen forskel på
> koden i de to filer. Den ene virker - men den anden gør ikke?
Prøv at læse siden her < http://asp-faq.dk/article/?id=41>
og stil derefter spørgsmålet i asp-gruppen:
<news:dk.edb.internet.webdesign.servertside.asp>.
> Hvis det er et serverside problem, ved du så noget om det?
Det er der mange der gør i asp-gruppen.
NB: Læs gerne min signatur.
FUT: <news:dk.edb.internet.webdesign.servertside.asp>
Om FUT og X-FUT: < http://www.usenet.dk/ord/lokal.html#fut>
--
Jens Gyldenkærne Clausen
Svar venligst under det du citerer, og citer kun det der er
nødvendigt for at forstå dit svar i sammenhængen. Se hvorfor og
hvordan på http://usenet.dk/netikette/citatteknik.html
| |
|
|