Forums

ASP

This topic is locked

Can't insert records ( Access database )

Posted 25 Jul 2007 15:22:40
1
has voted
25 Jul 2007 15:22:40 Zhanat Zhanibekov posted:
Hi everybody
I have developed library-cataloge on my local web-server(winXPsp2, IIS5)
Then I moved my web-site to Company' server (Win Server2003, IIS6, Access 2000)
Everything work just fine on my local server. However, when i have transfered the web-site to Company's Server, one of my pages is not working. Update,Delete, Insert recordset work without problems, while Insert recordset of the one page dont work at all, giving HTTP 500 errors in Company' server.
This is the code of the problematic page:


<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/dsn_avril.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") = "form3" Then

MM_editConnection = MM_dsn_avril_STRING
MM_editTable = "Kz"
MM_editRedirectUrl = "insert_kz.asp"
MM_fieldsStr = "ID|value|Element|value|Element2|value|Element3|value|Element4|value|Element5|value|Element6|value|Element7|value|Element8|value"
MM_columnsStr = "ID|none,none,NULL|Àâòîð|',none,''|Íàçâàíèå|',none,''|Èçäàòåëüñòâî|',none,''|Ãîðîä|',none,''|Ãîä|none,none,NULL|Ñòðàíà|',none,''|Íàëè÷èå|',none,''|Ïðèìå÷àíèå|',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
%>
<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset"
Recordset1.ActiveConnection = MM_dsn_avril_STRING
Recordset1.Source = "SELECT * FROM Kz"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>
<%
' *** Recordset Stats, Move To Record, and Go To Record: declare stats variables

Dim Recordset1_total
Dim Recordset1_first
Dim Recordset1_last

' set the record count
Recordset1_total = Recordset1.RecordCount

' set the number of rows displayed on this page
If (Recordset1_numRows < 0) Then
Recordset1_numRows = Recordset1_total
Elseif (Recordset1_numRows = 0) Then
Recordset1_numRows = 1
End If

' set the first and last displayed record
Recordset1_first = 1
Recordset1_last = Recordset1_first + Recordset1_numRows - 1
Recordeset1_zhanat=recordset1_total + 1

' if we have the correct record count, check the other stats
If (Recordset1_total <> -1) Then
If (Recordset1_first > Recordset1_total) Then
Recordset1_first = Recordset1_total
End If
If (Recordset1_last > Recordset1_total) Then
Recordset1_last = Recordset1_total
End If
If (Recordset1_numRows > Recordset1_total) Then
Recordset1_numRows = Recordset1_total
End If
End If
%>
<%
' *** Recordset Stats: if we don't know the record count, manually count them

If (Recordset1_total = -1) Then

' count the total records by iterating through the recordset
Recordset1_total=0
While (Not Recordset1.EOF)
Recordset1_total = Recordset1_total + 1
Recordset1.MoveNext
Wend

' reset the cursor to the beginning
If (Recordset1.CursorType > 0) Then
Recordset1.MoveFirst
Else
Recordset1.Requery
End If

' set the number of rows displayed on this page
If (Recordset1_numRows < 0 Or Recordset1_numRows > Recordset1_total) Then
Recordset1_numRows = Recordset1_total
End If

' set the first and last displayed record
Recordset1_first = 1



Recordset1_last = Recordset1_first + Recordset1_numRows - 1

If (Recordset1_first > Recordset1_total) Then
Recordset1_first = Recordset1_total
End If
If (Recordset1_last > Recordset1_total) Then
Recordset1_last = Recordset1_total

End If

End If
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/template.dwt.asp" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Âñòàâèòü çàïèñü â áèáëèîòåêó</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->

<link href="style/styles.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body {
background-color: #FFFFFF;
}
.style2 {font-size: 14px}
.style3 {color: #3E0000}
.style5 {
font-family: "Courier New", Courier, mono;
font-size: 24px;
color: #000000;
}
.style6 {font-family: "Courier New", Courier, mono}
.style8 {font-size: 14px; font-family: "Times New Roman", Times, serif; }
-->
</style></head>

<body>
<form name="form1" id="form1" method="post" action="">
<table height="67" border="1" bordercolor="#000000" class="bg_blue">
<tr>
<td width="979"><div align="center" class="bg_blue style3 style5"><strong>Электронный каталог</strong></div></td>
</tr>
</table>
<table width="985" height="32" border="1" bordercolor="#000000" bgcolor="#003366" class="menu">
<tr bgcolor="#0066FF" class="bg_blue">
<td width="476" height="26" class="menu"><div align="center" class="style6"><span class="style8"><a href="kazakh.asp" class="menu">Ëèòåðàòóðà íà ãîñóäàðñòâåííîì ÿçûêå </a></span></div></td>
<td width="459" class="menu"><div align="center" class="style6"></div>
<div align="center" class="style6"><span class="style2"><a href="general.asp" class="menu">Ëèòåðàòóðà íà ðóññêîì ÿçûêå </a></span></div></td>
<td width="28"><p align="center" class="style2"><a href="admin.asp"><img src="pic/edit.jpg" width="28" height="22" border="0" /></a> </p></td>
</tr>
</table>
</form>

<!-- InstanceBeginEditable name="main" -->
<form name="form2" id="form2" method="post" action="">
</form>

<form method="post" action="<%=MM_editAction%>" name="form3">
<table border="1" align="center" bordercolor="#000000">
<tr valign="baseline" class="body_table">
<td nowrap align="right">ID:</td>
<td><input name="ID" type="text" value="<%=(Recordset1_total+1)%>" size="32" /></td>
</tr>
<tr valign="baseline" class="body_table">
<td nowrap align="right">Àâòîð:</td>
<td><input type="text" name="Element" value="" size="32">
</td>
</tr>
<tr valign="baseline" class="body_table">
<td nowrap align="right">Íàçâàíèå:</td>
<td><input type="text" name="Element2" value="" size="32">
</td>
</tr>
<tr valign="baseline" class="body_table">
<td nowrap align="right">Èçäàòåëüñòâî:</td>
<td><input type="text" name="Element3" value="" size="32">
</td>
</tr>
<tr valign="baseline" class="body_table">
<td nowrap align="right">Ãîðîä:</td>
<td><input type="text" name="Element4" value="" size="32">
</td>
</tr>
<tr valign="baseline" class="body_table">
<td nowrap align="right">Ãîä:</td>
<td><input type="text" name="Element5" value="" size="32">
</td>
</tr>
<tr valign="baseline" class="body_table">
<td nowrap align="right">Ñòðàíà:</td>
<td><input type="text" name="Element6" value="" size="32">
</td>
</tr>
<tr valign="baseline" class="body_table">
<td nowrap align="right">Íàëè÷èå:</td>
<td><input type="text" name="Element7" value="" size="32">
</td>
</tr>
<tr valign="baseline" class="body_table">
<td nowrap align="right">Ïðèìå÷àíèå:</td>
<td><input type="text" name="Element8" value="" size="32">
</td>
</tr>
<tr valign="baseline" class="body_table">
<td nowrap align="right"> </td>
<td><input type="submit" value="Âñòàâèòü çàïèñü">
</td>
</tr>
</table>
<p>
<input type="hidden" name="MM_insert" value="form3">
</p>
<p><a href="tasks.asp">Âåðíóòüñÿ íà ãëàâíîå ìåíþ </a></p>
</form>
<p> </p>
<!-- InstanceEndEditable -->


<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<table width="983" border="0">
<tr>
<td width="957" height="18" class="style2"><div align="center" class="back">
<p><span class="back"><Hr align="center" width="700" NoShade color="#400000">
Copyright</span> © 2005 - 2007 г. АОДТ АО "Казахтелеком"</p>
</div></td>
</tr>
</table>
</body>
<!-- InstanceEnd --></html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>


Please anyone who can fix this problem help me
Thanx in advance!!!!!!!!!!!

Reply to this topic