Forums
This topic is locked
Problem with connecting to database...
Posted 10 Sep 2001 08:31:42
1
has voted
10 Sep 2001 08:31:42 Michael Reiner posted:
There is a little Problem, with my connection to a Access Database... every time i try to connect to a database, I can´t enter new data! If I just view the data that is in the database, there is no problem. But he always tells me that there is a Error in the line that tells him to onsert the new data.... I build the page with the Live insert Formular for Datapages (don´t know if this is the correct name)P.S.: Sorry for the bad english
Replies
Replied 11 Sep 2001 08:57:25
11 Sep 2001 08:57:25 Michael Reiner replied:
In addition the Error message reads:
HTTP 500.100 - Internal Server Error - ASP error
Internet Information Services
--------------------------------------------------------------------------------
Technical Information (for support personnel)
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
/temp/index.asp, line 90
Browser Type:
Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)
Page:
POST 61 bytes to /temp/index.asp
POST Data:
Nachname=s&Vorname=h&Mailadresse=i&Text=ojpoij&MM_insert=true
Time:
Tuesday, September 11, 2001, 8:58:35 AM
More information:
Microsoft Support
HTTP 500.100 - Internal Server Error - ASP error
Internet Information Services
--------------------------------------------------------------------------------
Technical Information (for support personnel)
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
/temp/index.asp, line 90
Browser Type:
Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)
Page:
POST 61 bytes to /temp/index.asp
POST Data:
Nachname=s&Vorname=h&Mailadresse=i&Text=ojpoij&MM_insert=true
Time:
Tuesday, September 11, 2001, 8:58:35 AM
More information:
Microsoft Support
Replied 12 Sep 2001 01:16:30
12 Sep 2001 01:16:30 Viktor Farcic replied:
You must send us your code.
Replied 12 Sep 2001 08:08:22
12 Sep 2001 08:08:22 Michael Reiner replied:
Here now the code, the Page lies in the directory /temp and the appropriate database connection ist tested, and i´m able to view the data with another page... so teh connection should be all right.
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="../Connections/connTest.asp" -->
<%
' *** Edit Operations: declare variables
MM_editAction = CStr(Request("URL")
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 = ""
%>
<%
' *** Insert Record: set variables
If (CStr(Request("MM_insert") <> "" Then
MM_editConnection = MM_connTest_STRING
MM_editTable = "Tabelle1"
MM_editRedirectUrl = ""
MM_fieldsStr = "Nachname|value|Vorname|value|Mailadresse|value|Text|value"
MM_columnsStr = "Nachname|',none,''|Vorname|',none,''|Mailadresse|',none,''|Text|',none,''"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|"
MM_columns = Split(MM_columnsStr, "|"
' set the form values
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(i+1) = CStr(Request.Form(MM_fields(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
If (CStr(Request("MM_insert") <> "" Then
' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
FormVal = MM_fields(i+1)
MM_typeArray = Split(MM_columns(i+1),","
Delim = MM_typeArray(0)
If (Delim = "none" Then Delim = ""
AltVal = MM_typeArray(1)
If (AltVal = "none" Then AltVal = ""
EmptyVal = MM_typeArray(2)
If (EmptyVal = "none" Then EmptyVal = ""
If (FormVal = "" Then
FormVal = EmptyVal
Else
If (AltVal <> "" Then
FormVal = AltVal
ElseIf (Delim = "'" Then ' escape quotes
FormVal = "'" & Replace(FormVal,"'","''" & "'"
Else
FormVal = Delim + FormVal + Delim
End If
End If
If (i <> LBound(MM_fields)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End if
MM_tableValues = MM_tableValues & MM_columns(i)
MM_dbValues = MM_dbValues & 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
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<form method="post" action="<%=MM_editAction%>" name="form1">
<table align="center" width="402">
<tr valign="baseline">
<td nowrap align="right" width="76" height="30">Nachname:</td>
<td valign="top" colspan="2">
<input type="text" name="Nachname" value="" size="55">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right" height="30">Vorname:</td>
<td valign="top" colspan="2">
<input type="text" name="Vorname" value="" size="55">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right" height="30">Mailadresse:</td>
<td valign="top" colspan="2">
<input type="text" name="Mailadresse" value="" size="55">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right" height="30">Text:</td>
<td valign="top" colspan="2" rowspan="2">
<textarea name="Text" cols="55" rows="25"></textarea>
</td>
</tr>
<tr valign="baseline">
<td height="336"></td>
</tr>
<tr>
<td height="35" colspan="2" valign="top" nowrap align="right"> </td>
<td width="160" valign="top">
<input type="submit" value="Datensatz einfügen">
</td>
</tr>
<tr>
<td height="5"></td>
<td width="144"></td>
<td></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="true">
</form>
<p> </p>
</body>
</html>
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="../Connections/connTest.asp" -->
<%
' *** Edit Operations: declare variables
MM_editAction = CStr(Request("URL")
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 = ""
%>
<%
' *** Insert Record: set variables
If (CStr(Request("MM_insert") <> "" Then
MM_editConnection = MM_connTest_STRING
MM_editTable = "Tabelle1"
MM_editRedirectUrl = ""
MM_fieldsStr = "Nachname|value|Vorname|value|Mailadresse|value|Text|value"
MM_columnsStr = "Nachname|',none,''|Vorname|',none,''|Mailadresse|',none,''|Text|',none,''"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|"
MM_columns = Split(MM_columnsStr, "|"
' set the form values
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(i+1) = CStr(Request.Form(MM_fields(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
If (CStr(Request("MM_insert") <> "" Then
' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
FormVal = MM_fields(i+1)
MM_typeArray = Split(MM_columns(i+1),","
Delim = MM_typeArray(0)
If (Delim = "none" Then Delim = ""
AltVal = MM_typeArray(1)
If (AltVal = "none" Then AltVal = ""
EmptyVal = MM_typeArray(2)
If (EmptyVal = "none" Then EmptyVal = ""
If (FormVal = "" Then
FormVal = EmptyVal
Else
If (AltVal <> "" Then
FormVal = AltVal
ElseIf (Delim = "'" Then ' escape quotes
FormVal = "'" & Replace(FormVal,"'","''" & "'"
Else
FormVal = Delim + FormVal + Delim
End If
End If
If (i <> LBound(MM_fields)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End if
MM_tableValues = MM_tableValues & MM_columns(i)
MM_dbValues = MM_dbValues & 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
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<form method="post" action="<%=MM_editAction%>" name="form1">
<table align="center" width="402">
<tr valign="baseline">
<td nowrap align="right" width="76" height="30">Nachname:</td>
<td valign="top" colspan="2">
<input type="text" name="Nachname" value="" size="55">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right" height="30">Vorname:</td>
<td valign="top" colspan="2">
<input type="text" name="Vorname" value="" size="55">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right" height="30">Mailadresse:</td>
<td valign="top" colspan="2">
<input type="text" name="Mailadresse" value="" size="55">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right" height="30">Text:</td>
<td valign="top" colspan="2" rowspan="2">
<textarea name="Text" cols="55" rows="25"></textarea>
</td>
</tr>
<tr valign="baseline">
<td height="336"></td>
</tr>
<tr>
<td height="35" colspan="2" valign="top" nowrap align="right"> </td>
<td width="160" valign="top">
<input type="submit" value="Datensatz einfügen">
</td>
</tr>
<tr>
<td height="5"></td>
<td width="144"></td>
<td></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="true">
</form>
<p> </p>
</body>
</html>