#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    1
    Rep Power
    0

    ASP/SQL programming newbie... need help.


    I am having problems trying to update a record in a SQL database.. I have one page that has records display and then have a link to update the data. It sends you to another page that is just that record with editable form fields with the data in it to be update. This second page is coming up broken.. Here are the two pages.



    updatestat.asp

    <%
    'Dimension variables
    Dim todaysDate
    Dim adoCon 'Holds the Database Connection Object
    Dim rsIssues'Holds the recordset for the records in the database
    Dim strSQL 'Holds the SQL query for the database
    Dim Page
    Dim RowCount
    Dim PageCounter

    Page = Request.QueryString("Page")

    'If there is no page set it to page 1
    If Page = "" then
    Page = 1
    End if

    RowCount = 0

    Set adoCon = Server.CreateObject("ADODB.Connection")
    Set rsIssues = Server.CreateObject("ADODB.Recordset")
    strSQL = "SELECT * FROM dbo.stattbl"
    adoCon.Open "Provider=sqloledb;SERVER=TESTDB2.partners.org;DATABASE=nuclear;UID=cardnorth;PWD=hockey1;"
    rsIssues.CursorType = 3
    rsIssues.PageSize = 10
    rsIssues.Open strSQL, adoCon
    rsIssues.AbsolutePage = cInt(Page)
    %>
    Current page <b><%=Request.Querystring("page")%></b></div>
    </td>
    </tr>
    <tr>
    <td>
    <table width="100%" border="0" cellspacing="1" cellpadding="0" bgcolor="#000000">
    <tr align="center" class="body">
    <td colspan="5" class="Med_whitetxt"><b> ADMIN</b></td>
    </tr>
    <tr>
    <td>
    <input type="BUTTON" value="SUBMIT POSTING" onClick="window.location.href='statlogsubmit.asp'" name="BUTTON2"/>
    </td>
    <td>
    <input type="BUTTON" value="VIEW POSTINGS" onClick="window.location.href='viewallstat.asp'" name="BUTTON22"/>
    </td>
    <td>
    <input type="BUTTON" value="EDIT RECORD" onClick="window.location.href='updatestat.asp'" name="BUTTON3"/>
    </td>
    <td>
    <input type="BUTTON" value="DELETE RECORD" onClick="window.location.href='delete_recordstat.asp'" name="BUTTON32"/>
    </td>
    <td>
    <input type="BUTTON" value="Filter Records" onClick="window.location.href='filterstat.asp'" name="BUTTON32"/>
    </td>
    </tr>
    </table>
    </td>
    </tr>
    <% Do while not rsIssues.eof and RowCount < rsIssues.PageSize %>
    <tr>
    <td>
    <table cellspacing="0" cellpadding="0" border="1" width="100%">
    <tr>
    <td align="left" colspan="2">&nbsp; </td>
    </tr>
    <tr>
    <td align="left" width="30%"> <strong>ID:</strong>
    </td>
    <td align="left">
    <% Response.Write (rsIssues("Identity")) %>
    </td>
    </tr>
    <tr>
    <td align="left" width="30%"> <strong>Date:</strong>
    </td>
    <td align="left">
    <% Response.Write (rsIssues("date")) %>
    </td>
    </tr>
    <tr>
    <td align="left"><b>First Name<strong>:</strong>
    </b></td>
    <td align="left">
    <% Response.Write (rsIssues("firstname")) %>
    </td>
    </tr>
    <tr>
    <td align="left"><b>Last Name<strong>:</strong> </b></td>
    <td align="left">
    <% Response.Write (rsIssues("lastname")) %>
    </td>
    </tr>
    <tr>
    <td align="left"><b>MRN<strong>:</strong> </b></td>
    <td align="left">
    <% Response.Write (rsIssues("mrn")) %>
    </td>
    </tr>
    <tr>
    <td align="left"><b>Date of Study<strong>:</strong> </b></td>
    <td align="left">
    <% Response.Write (rsIssues("dos")) %>
    </td>
    </tr>
    <tr>
    <td align="left"><b>Study<strong>:</strong> </b></td>
    <td align="left">
    <% Response.Write (rsIssues("study")) %>
    </td>
    </tr> <tr>
    <td align="left"><b>Date Of Study<strong>:</strong> </b></td>
    <td align="left">
    <% Response.Write (rsIssues("dos")) %>
    </td>
    </tr> <tr>
    <td align="left"><b>Referring Physician<strong>:</strong> </b></td>
    <td align="left">
    <% Response.Write (rsIssues("referring")) %>
    </td>
    </tr> <tr>
    <td align="left"><b>Reading Physician<strong>:</strong> </b></td>
    <td align="left">
    <% Response.Write (rsIssues("reading")) %>
    </td>
    </tr> <tr>
    <td align="left"><b>IN/OUT/ES<strong>:</strong> </b></td>
    <td align="left">
    <% Response.Write (rsIssues("ioe")) %>
    </td>
    </tr> <tr>
    <td align="left"><b>Location<strong>:</strong> </b></td>
    <td align="left">
    <% Response.Write (rsIssues("location")) %>
    </td>
    </tr> <tr>
    <td align="left"><b>Tech<strong>:</strong> </b></td>
    <td align="left">
    <% Response.Write (rsIssues("tech")) %>
    </td>
    </tr> <tr>
    <td align="left"><b>Stat/Routine<strong>:</strong> </b></td>
    <td align="left">
    <% Response.Write (rsIssues("stat")) %>
    </td>
    </tr>
    <tr>
    <td align="left"><strong>Diagnosis</strong></td>
    <td align="left"><% Response.Write (rsIssues("diagnosis")) %></td>
    </tr>
    <tr>
    <td align="left"><strong>Insurance</strong></td>
    <td align="left"><% Response.Write (rsIssues("insurance1")) %></td>
    </tr>
    <tr>
    <td align="left"><strong>Write in Insurance </strong></td>
    <td align="left"><% Response.Write (rsIssues("insurance2")) %></td>
    </tr>
    <tr>
    <td align="left"><strong>Authorization Number </strong></td>
    <td align="left"><% Response.Write (rsIssues("authno")) %></td>
    </tr>
    <tr>
    <td align="left"><b>Other Comments<strong>:</strong>
    </b></td>
    <td align="left">
    <% Response.Write (rsIssues("comments")) %>
    </td>
    </tr>
    <tr>
    <td align="left">&nbsp;</td>
    <td align="left"><strong><a href="update_formstat.asp?ID=<% Response.Write (rsIssues("Identity")) %>">Update Entry</a></strong> </td>
    </tr>
    </table>
    <table width="100%" border="0">
    <tr>
    <td class="body">&nbsp;</td>
    </tr>
    </table>
    </td>
    </tr>
    <% 'Write the HTML to display the current record in the recordset
    rsIssues.Movenext
    RowCount = RowCount + 1
    Loop
    %>
    <tr>
    <td bordercolor="#666666" align="Middle">
    <%For PageCounter = 1 to rsIssues.PageCount %>
    <a href='update.asp?Page=<%=PageCounter %>' class='myclass'>Page
    <%=PageCounter %></a>
    <%Next%>
    </td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    <p><br>
    </p>
    <blockquote>&nbsp;</blockquote>
    </td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    </tr>
    </tbody>
    </table>
    <!-- InstanceEndEditable -->
    </td>
    </tr>
    </tbody>
    </table>
    </html>






    update_formstat.asp





    <%

    '****************************************************************************************



    'Dimension variables
    Dim adoCon 'Holds the Database Connection Object
    Dim rsIssues 'Holds the recordset for the record to be updated
    Dim strSQL 'Holds the SQL query for the database
    Dim lngRecordNo 'Holds the record number to be updated


    'Read in the record number to be updated
    lngRecordNo = CLng(Request.QueryString("ID"))

    'Create an ADO connection odject
    Set adoCon = Server.CreateObject("ADODB.Connection")


    'Set an active connection to the Connection object using DSN connection

    adoCon.Open "Provider=sqloledb;SERVER=TESTDB2.partners.org;DATABASE=nuclear;UID=cardnorth;PWD=hockey1;"


    Set rsIssues = Server.CreateObject("ADODB.Recordset")


    'Initialise the strSQL variable with an SQL statement to query the database
    strSQL = "SELECT * FROM dbo.stattbl WHERE ID=" & lngRecordNo



    'Set the cursor type we are using so we can navigate through the recordset
    rsIssues.CursorType = 2

    'Set the lock type so that the record is locked by ADO when it is updated
    rsIssues.LockType = 3

    'Open the recordset with the SQL query
    'adoCon.Open adoCon
    rsIssues.Open strSQL, adoCon





    %>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><!-- InstanceBegin template="/Templates/Ice Department SubWeb.dwt" codeOutsideHTMLIsLocked="false" --><head><!-- InstanceBeginEditable name="EditRegion3" --><title> IT</title>

    </script></head><body style="background-color: rgb(255, 255, 255);">
    <div id="Layer1" class="newtexttop" style="position: absolute; left: 309px; top: 36px; width: 447px; height: 36px; z-index: 1;">
    <div class="newtexttop" align="center">
    <!-- InstanceBeginEditable name="EditRegion2" -->
    Cardiology IT
    <!-- InstanceEndEditable -->
    </div>
    </div>
    <div id="Layer2" style="position: absolute; left: 290px; top: 81px; width: 448px; height: 18px; z-index: 2;"><font color="#003399" face="arial" size="2">
    </font>
    </div>
    <script type="text/javascript">function Go(){return}</script>
    <script type="text/javascript" src="img/SinglePage_var.js"></script>
    <script type="text/javascript" src="img/menu131_com.js"></script>
    <table border="0" cellpadding="0" cellspacing="0" width="780">
    <tbody>
    <tr bgcolor="#ffffff">
    <td colspan="2" height="100"><img src="ice.jpg" usemap="#map" border="0" height="100" width="780"></td>
    </tr>
    <tr>
    <td bgcolor="#669acc" height="554" width="86" valign="top" align="center">
    <img src="imh/spacer.gif" width="86" height="1"></td>
    <td align="center" bgcolor="#ffffff" valign="top" width="684"> <!-- InstanceBeginEditable name="EditRegion4" -->
    <table border="0" cellpadding="0" cellspacing="0" width="658">
    <tbody>
    <tr>
    <td height="28">
    <p><img src="whitespacer.jpg" height="47" width="86"></p>
    </td>
    </tr>
    <tr>
    <td height="28">
    <table width="100%" border="0" cellspacing="1" cellpadding="3" height="25">
    <tr class="bgwhite">
    <td nowrap align="center"><a href="Index.asp" class="titles_purple">Home&nbsp;</a>&nbsp;</td>
    <td nowrap align="center">&nbsp;&nbsp;<a href="about.asp" class="titles_purple">About&nbsp;</a>&nbsp;
    </td>
    <td nowrap align="center"><a href="passwords.asp" class="titles_purple">&nbsp;&nbsp;Need
    a Password?</a>&nbsp;&nbsp;</td>
    <td nowrap align="center"><a href="problems.asp" class="titles_purple">&nbsp;&nbsp;FAQ
    / Support&nbsp;</a>&nbsp;</td>
    <td nowrap align="center"><a href="systems.asp" class="titles_purple">&nbsp;&nbsp;Systems
    Supported</a>&nbsp;&nbsp;</td>

    <td nowrap align="center"><a href="links.asp" class="titles_purple">&nbsp;Links</a>&nbsp;&nbsp;</td>
    <td align="center"><a href="contacts.asp" class="titles_purple">&nbsp;&nbsp;Contacts&nbsp;&nbsp;</a></td>
    </tr>
    </table>
    </td>
    </tr>
    <tr>
    <td height="28">&nbsp;</td>
    </tr>
    <tr>
    <td><a href="#" onClick="history.back()">&nbsp;&nbsp;&nbsp; Back</a></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <tr>
    <td></td>
    </tr>
    <td class="Contextitle"> System Issue Log - Admin</td>
    </tr>
    <tr>
    <td class="sm_navytxt" valign="top">&nbsp;</td>
    </tr>
    <tr>
    <td class="sm_navytxt" valign="top"><a href="systemlog.asp">SUBMIT</a>
    / <a href="viewall.asp">VIEW ALL</a> / <a href="filter.asp">SEARCH</a></td>
    </tr>
    <tr>
    <td align="left">
    <table width="100%" border="0" cellspacing="1" cellpadding="0" class="body">
    <tr>
    <td class="bgwhite">
    <table width="800" border="0" cellspacing="1" cellpadding="0" class="body">
    <tr class="bgwhite">
    <td align="center"><table width="100%" border="0" cellspacing="1" cellpadding="0" bgcolor="#000000">
    <tr align="center" class="body">
    <td colspan="5" class="Med_whitetxt"><b> ADMIN</b></td>
    </tr>
    <tr>
    <td><input type="BUTTON" value="SUBMIT POSTING" onClick="window.location.href='statlogsubmit.asp'" name="BUTTON2"/>
    </td>
    <td><input type="BUTTON" value="VIEW POSTINGS" onClick="window.location.href='viewallstat.asp'" name="BUTTON22"/>
    </td>
    <td><input type="BUTTON" value="EDIT RECORD" onClick="window.location.href='updatestat.asp'" name="BUTTON3"/>
    </td>
    <td><input type="BUTTON" value="DELETE RECORD" onClick="window.location.href='delete_recordstat.asp'" name="BUTTON32"/>
    </td>
    <td><input type="BUTTON" value="Filter Records" onClick="window.location.href='filterstat.asp'" name="BUTTON32"/>
    </td>
    </tr>
    </table></td>
    </tr>
    </table>


    <form name="form" method="post" action="update_entrystat.asp">

    <table cellspacing="0" cellpadding="0" border="1" width="100%">
    <tr>
    <td align="left" colspan="2">&nbsp;</td>
    </tr>
    <tr align="center" bgcolor="#CCCCCC">
    <td colspan="2">Issue #
    <% Response.Write (rsIssues("identity")) %> </td>
    </tr>
    <tr>
    <td align="left" width="30%"> <strong>Date:</strong> </td>
    <td align="left">
    <input type="text" name="date" size="40" value="<% = rsIssues("date") %>"> </td>
    </tr>
    <tr>
    <td align="left"><b>First Name<strong>:</strong> </b></td>
    <td align="left">
    <input type="text" name="firstname" size="40" value="<% = rsIssues("firstname") %>"> </td>
    </tr>
    <tr>
    <td align="left"><b>Location<strong>:</strong> </b></td>
    <td align="left">
    <input type="text" name="lastname" size="40" value="<% = rsIssues("lastname") %>"> </td>
    </tr>

    <tr>
    <td align="left"><b>MRN<strong>:</strong> </b></td>
    <td align="left">
    <input name="mrn" type="text" value="<% = rsIssues("mrn") %>" size="40"> </td>
    </tr>

    <tr>
    <td align="left">&nbsp;</td>
    <td align="left">&nbsp;</td>
    </tr>
    </table>
    <p/></p>
    <div align="center">
    <input type="hidden" name="ID" value="<% = rsIssues("Identity") %>">
    <input type="submit" value="Update" name="submit">
    </div>
    </form>
    </td>
    </tr>
    </table>
    <p><br>
    </p>
    <blockquote>&nbsp;</blockquote>
    </td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    </tr>

    </table>



    <!-- InstanceEndEditable -->
    </td>
    </tr>
    </tbody>
    </table>
    <%
    'Reset server objects
    rsIssues.Close
    Set rsIssues = Nothing
    Set adoCon = Nothing
    %>



    </html>
  2. #2
  3. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,439
    Rep Power
    4539
    Use forum code tags around posted code. And simply posting all your code without describing the steps you've taken to try to isolate the problem doesn't encourage anyone to look over your code.
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester

IMN logo majestic logo threadwatch logo seochat tools logo