Get ready for BLACK FRIDAY shopping starting in

Forums

This topic is locked

not inserting record

Posted 29 May 2002 06:44:14
1
has voted
29 May 2002 06:44:14 chris espino posted:
wondering if anybody can help me, I can't seem to insert any record. there's current record on the table, after manually entering it. all queries work fine, so this is baffling me a bit. I'm using the insert behaviour.

thanks in advance!

------------------------------------------------

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/ReportsSQL.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 = ""
%>
<%
' *** 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 = ""
%>
<%
' *** Insert Record: set variables

If (CStr(Request("MM_insert") = "create" Then

MM_editConnection = MM_ReportsSQL_STRING
MM_editTable = "dbo.tblReport"
MM_editRedirectUrl = "verify_input.asp"
MM_fieldsStr = "project|value|e_mail|value|date|value|report|value"
MM_columnsStr = "project|',none,''|e_mail|',none,''|date|',none,NULL|report|',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 ReportsSQL__varUsername
ReportsSQL__varUsername = "1234"
if (Session("MM_Username" <> "" then ReportsSQL__varUsername = Session("MM_Username"
%>
<%
set ReportsSQL = Server.CreateObject("ADODB.Recordset"
ReportsSQL.ActiveConnection = MM_ReportsSQL_STRING
ReportsSQL.Source = "SELECT tblUser.fname, tblUser.lname, tblUser.e_mail, tblReport.e_mail, tblReport.project, tblReport.report, tblReport.date FROM tblReport, tblUser WHERE tblUser.e_mail = tblReport.e_mail and tblUser.e_mail = '" + Replace(ReportsSQL__varUsername, "'", "''" + "'"
ReportsSQL.CursorType = 0
ReportsSQL.CursorLocation = 2
ReportsSQL.LockType = 3
ReportsSQL.Open()
ReportsSQL_numRows = 0
%>
<html>
<head>
<title>Reports Create Report</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="../reports/sample.css" type="text/css">
<script language="JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'";
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
<link href="sample.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>  </p>
<p> </p>
<div id="Layer2" style="position:absolute; width:600px; height:31px; z-index:3; left: 8px; top: 24px" class="text_heading"></div>
<div id="Layer3" style="position:absolute; width:135px; height:16px; z-index:5; left: 15px; top: 33px">Hello
<%=(ReportsSQL.Fields.Item("fname".Value)%>! </div>
<div id="jump" style="position:absolute; width:160px; height:34px; z-index:4; left: 469px; top: 29px; visibility: visible" class="text_headingBig">
<form name="jump" >
<select name="menu1" onChange="MM_jumpMenu('parent',this,0)" class="jumpList">
<option value=" " selected>Menu</option>
<option value="reports1.asp">Home</option>
<option value="create.asp">Create Report</option>
<option value=" ">Department Report</option>
<option>Logout</option>
</select>
<input type="button" name="jumpButton" value="Go" onClick="MM_jumpMenuGo('menu1','parent',0)" class="jumpButton">
</form>
</div>
new
<form ACTION="<%=MM_editAction%>" METHOD="POST" name="create" enctype="multipart/form-data">
<p>
<select name="project">
<option value="Null">Project</option>
<option value="DW3" selected>DW3</option>
</select>
<input type="text" name="e_mail" value=" ">
<input type="text" name="date">
<br>
<textarea name="report" cols="70" rows="15"></textarea>
<br>
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
<input type="hidden" name="MM_insert" value="create">
</form>
<p> </p>
<p><br>
<br>
<br>
</p>
<p> </p>
<p> </p>
<p> </p>
</body>
</html>
<%
ReportsSQL.Close()
%>




Edited by - diggable on 29 May 2002 06:46:05

Replies

Replied 29 May 2002 09:24:43
29 May 2002 09:24:43 Viktor Farcic replied:
What's the error message?

Viktor Farcic

TalkZone Manager
Replied 30 May 2002 00:16:28
30 May 2002 00:16:28 chris espino replied:
I'm not getting an error message, it goes back to the same form clearing out the entered data.

no entered data goes to the database either.

i'm sure there's something missing.


thanks!

Reply to this topic