all groups > inetserver asp db > july 2003 >
You're in the

inetserver asp db

group:

Load Empty Recordset


Load Empty Recordset Gary D. Rezek
7/29/2003 3:23:29 PM
inetserver asp db:
Hi All,
Is it possible to load an empty recordset into a page for the purpose of setting up the page for a new record?
The following code
(there is also a Case "edit" and a Case "delete" which work fine)
CASE "add"
strSQL = "SELECT * "
strSQL = strSQL & "FROM tblPatents " strSQL = strSQL & "WHERE PatentID = 0;"
Set rst = server.CreateObject("ADODB.Recordset")
rst.Open strSQL, cnMain, 1, 3, &H0001

Gives me the following error

Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

Which I certainly agree with, but is there a way around it. My page's controls use value=<%= rst("Value")%> for their value so I
can't (at least to my knowledge) not have a recordset.
Thank you.

gdr
--
Gary D. Rezek
University Networking Services
South Dakota State University

Re: Load Empty Recordset Gary D. Rezek
7/29/2003 4:00:40 PM
Hi Ray,
I'm trying to setup a page somewhat based on the ASP101 Database Editing sample
http://www.asp101.com/samples/db_edit.asp (using asp source code)
Where they are building a page (form) to do the edit and AddNew procedures I want to use a "pre-defined" page; i.e. (in this
case) ResearcherStaffPatents.asp; for both the edit and AddNew records. Also they add the new values programmatically in the
AddNew portion of their example which I cannot seem to use for my purpose.
Thank you.

gdr


[quoted text, click to view]

Re: Load Empty Recordset Ray at <%=sLocation%
7/29/2003 4:29:32 PM
What is it that you're trying to accomplish?

Ray at work

[quoted text, click to view]

Re: Load Empty Recordset Gary D. Rezek
7/29/2003 8:36:51 PM
I'm sorry about this, but I don't know how else to go about it, so I really hope this helps.

This deals with 2 pages:
ResearcherStaffPatents.asp - which is where I want to be able to Add or Edit records.
ResearcherStaffPatent_AddEdit.asp - which has a listing of all of a participants patents and they may chose to delete or add or
edit a particular patent.

Below is the code on page ResearcherStaffPatents.asp. It is being 'called' by ResearcherStaffPatent_AddEdit.asp by using a
querystring action, like so:
<a href="ResearcherStaffPatents.asp?action=edit&id=<%= rst.Fields("Patentid").Value %>">Edit</a>
<a href="ResearcherStaffPatents.asp?action=delete&id=<%= rst.Fields("Patentid").Value %>">Delete</a>
<a href="ResearcherStaffPatents.asp?action=add">Add a new record</a>
**********************************************************************************
**ResearcherStaffPatents.asp**
<<connection info, DIM's, etc>>
strAction = LCase(Trim(Request.QueryString("action")))
SELECT CASE strAction
CASE "edit"
<<this works>>
CASE "delete"
<<this works>>
CASE "add"
strSQL = "SELECT * " 'using * until this works
strSQL = strSQL & "FROM tblPatents "
strSQL = strSQL & "WHERE PatentID = 0;"
'-----------------------------------------------------------
Set rst = server.CreateObject("ADODB.Recordset")
rst.Open strSQL, cnMain, 1, 3, &H0001
rst.AddNew
rst.Fields("ParticipantID") = intParticipantID
rst.Fields("PatentYear") = ""
rst.Fields("PatentNumber") = ""
rst.Fields("PatentTitle") = ""
rst.Fields("PatentStatus") = ""
rst.Fields("CampusIPO") = 0
rst.Fields("Authors") = ""
rst.Update
CASE Else
'do nothing
END SELECT
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<FORM action="ResearcherStaffPatent_AddEdit.asp" method=post id=ResearcherStaffPatents_AddEdit
name=ResearcherStaffPatents_AddEdit>
<P><FONT face=Arial><STRONG>PATENTS</STRONG></FONT></P><BR>
<P><FONT face=Arial size=2>Report only those patents awarded since January 1, 2001
acknowledging EPSCoR support. Do not report patents that are "pending". List all
staff who participated in patent writing.</FONT></P>
<P>
<TABLE cellSpacing=2 cellPadding=4 width="90%" border=0>

<TR>
<TD><STRONG>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Patent Year: </STRONG><INPUT id="txtPatentYear"
style="WIDTH: 100px; HEIGHT: 22px" size=59 value="<%=rst("PatentYear")%>" name="txtPatentYear" tabindex="1"></TD></TR>
<TR>
<TD><STRONG>Patent Number: </STRONG><INPUT id="txtPatentNumber"
style="WIDTH: 461px; HEIGHT: 22px" size=59 value="<%=rst("PatentNumber")%>" name="txtPatentNumber" tabindex="2"></TD></TR>
<TR>
<TD><STRONG>&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;Patent Title: </STRONG><INPUT id="txtPatentTitle"
style="WIDTH: 461px; HEIGHT: 22px" size=59 value="<%=rst("PatentTitle")%>" name="txtPatentTitle" tabindex="3"></TD></TR>
<TR>
<TD>&nbsp;&nbsp;&nbsp;<STRONG>Patent Status:</STRONG>
<INPUT id="radPatStatusApplied" type="radio" value="applied" name="radPatentStatus" tabindex="4" <%If
rst("PatentStatus")="applied" Then%>checked<%End If%>>&nbsp;Applied For
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<INPUT id="radPatStatusGranted" type="radio" value="granted" name="radPatentStatus" tabindex="5" <%If
rst("PatentStatus")="granted"Then%>checked<%End If%>>&nbsp;Granted</TD></TR>
<TR>
<TD><STRONG>Was the Patent Application through the Campus Intellectual Property Office?</STRONG>
<INPUT id="radCampusIPOYes" type="radio" value="Yes" name="radCampusIPO" tabindex="6" <%If rst("CampusIPO")= True
Then%>checked<%End If%>>&nbsp;Yes
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<INPUT id="radCampusIPONo" type="radio" value="No" name="radCampusIPO" tabindex="7" <%If rst("CampusIPO")= False
Then%>checked<%End If%>>&nbsp;No</TD></TR>
<TR>
<TD><STRONG>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Authors: </STRONG><INPUT id="txtAuthors"
style="WIDTH: 462px; HEIGHT: 22px" size=59 value="<%=rst("Authors")%>" name="txtAuthors" tabindex="8"></TD></TR>
</TABLE></P>
<P align=center>Please click on Submit to continue to the appropriate links to submit additional required
information.</P>
<P align="center">
<TABLE cellSpacing="1" cellPadding="1" width="50%" border="1">
<TR>
<TD>
<P align="center"><INPUT type=button id=submit1 name=submit1 value=Submit
onclick="location.href='ResearcherStaffPatent_AddEdit.asp?action=<%=strAction%>'"></P>
</TD>
<TD>
<P align="center"><INPUT id=reset1 type=reset value=Reset name=reset1></P>
</TD>
<TD>
<P align="center"><INPUT type=button id=Home name=Home value=Home onclick="location.href='home_rs.asp'"></P>
</TD>
<TD>
<P align="center"><INPUT type=button id=Logout name=Logout value=Logout onclick="location.href='Logout.asp'"></P>
</TD>
</TR>
</TABLE></P>
*********************************************************************************
<<And here is where I am stuck>>
If I use this the way Case "add" stands now, I will enter a new record, with no data except for the PatentID and ParticipantID,
just by clicking the <Add New Record> button from ResearcherStaffPatent_AddEdit.asp with no way to delete it if I leave the
ResearcherStaffPatents.asp page for some reason (I think, but I am quite new to .asp).
If I remove (comment out) all the references to the .AddNew rst.Fields("xxx") and try and use the empty recordset as the Record
Source to ResearcherStaffPatents.asp I get the error I mentioned in my first post. ( Either BOF or EOF is True, or the current
record has been deleted. Requested operation requires a current record.)
If I bypass the SQL statement, i.e. by just opening the form, the page error I get is, Type mismatch: 'rst', and then gives a
line number which references the 'rst' in the value criteria of txtPatentYear.

I hope this will give an idea of what I am trying to do and the problems I am having doing it.
Thank you.

gdr

[quoted text, click to view]
Re: Load Empty Recordset Ray at <%=sLocation%
7/29/2003 8:51:24 PM
Okay, so then what are you stuck on? How to get the column names from the
table? How to insert a record? Are you getting an error? What code do you
have so far?

Ray at home

--
Will trade ASP help for SQL Server help


[quoted text, click to view]

AddThis Social Bookmark Button