Load Empty Recordset

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Load Empty Recordset

    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


    Gary D. Rezek Guest

  2. Similar Questions and Discussions

    1. Show region if recordset is not empty
      Hi? How can I make server behavior for this?: If Diet field empty in the food table,Don?t display Diet word in the Page <% If Not Food.EOF...
    2. Show if recordset is empty??
      Hi, I have a results page with two result boxes and am trying to add 'Show if recordset is empty' for obvious reasons. BUT i've highlighted text...
    3. #25885 [Opn->Csd]: mail() causes apache2 to crash when message is empty, and headers is non-empty
      ID: 25885 Updated by: sniper@php.net Reported By: ben at krackeler dot com -Status: Open +Status: ...
    4. #25885 [NEW]: mail() causes apache2 to crash when message is empty, and headers is non-empty
      From: ben at krackeler dot com Operating system: WinXP PHP version: 4.3.3 PHP Bug Type: Mail related Bug description: ...
    5. Set an Empty Recordset?
      You could throw in a rsQuery.Movelast Sometimes what I'll do in testing is: CONST TRAP_STOP = 10 DIM TRAP_COUNT TRAP_COUNT = 1
  3. #2

    Default Re: Load Empty Recordset

    What is it that you're trying to accomplish?

    Ray at work

    "Gary D. Rezek" <Gary_Rezek@NOSPAMsdstate.edu> wrote in message
    news:%23KHmH9gVDHA.2104@TK2MSFTNGP10.phx.gbl...
    > 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
    >
    >

    Ray at Guest

  4. #3

    Default Re: Load Empty Recordset

    Hi Ray,
    I'm trying to setup a page somewhat based on the ASP101 Database Editing sample
    [url]http://www.asp101.com/samples/db_edit.asp[/url] (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


    "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message news:%2328wfAhVDHA.3332@tk2msftngp13.phx.gbl...
    > What is it that you're trying to accomplish?
    >
    > Ray at work
    >
    > "Gary D. Rezek" <Gary_Rezek@NOSPAMsdstate.edu> wrote in message
    > news:%23KHmH9gVDHA.2104@TK2MSFTNGP10.phx.gbl...
    > > 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
    > >
    > >
    >
    >

    Gary D. Rezek Guest

  5. #4

    Default Re: Load Empty Recordset

    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


    "Gary D. Rezek" <Gary_Rezek@NOSPAMsdstate.edu> wrote in message
    news:u$wU5RhVDHA.3924@tk2msftngp13.phx.gbl...
    > Hi Ray,
    > I'm trying to setup a page somewhat based on the ASP101 Database Editing
    sample
    > [url]http://www.asp101.com/samples/db_edit.asp[/url] (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
    >

    Ray at Guest

  6. #5

    Default Re: Load Empty Recordset

    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;Pa tent 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;&n bsp;&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;&n bsp;&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;&n bsp;&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_AddE dit.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

    "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message news:OFplNRjVDHA.612@TK2MSFTNGP10.phx.gbl...
    > 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
    >
    >
    > "Gary D. Rezek" <Gary_Rezek@NOSPAMsdstate.edu> wrote in message
    > news:u$wU5RhVDHA.3924@tk2msftngp13.phx.gbl...
    > > Hi Ray,
    > > I'm trying to setup a page somewhat based on the ASP101 Database Editing
    > sample
    > > [url]http://www.asp101.com/samples/db_edit.asp[/url] (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
    > >
    >
    >

    Gary D. Rezek Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139