p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 2.0 Professional (http://p2p.wrox.com/forumdisplay.php?f=215)
-   -   caching (http://p2p.wrox.com/showthread.php?t=54671)

jezywrap February 27th, 2007 05:00 PM

caching
 
I'm using C# using Gridview connection to SQL. What I'm trying to do is a user will login and will be redirected to a page with a list of their patients. This is what I have at the moment

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Web.Security" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Register TagPrefix="UserControl" TagName="Header" Src="Header.ascx" %>
<%@ Register TagPrefix="UserControl" TagName="Footer" Src="Footer.ascx" %>

<script language="C#" runat="server">

    String userID = "";

void Page_Load()
{

    userID = Convert.ToString(Cache.Get("ID"));

    Response.Write(userID);
}


</script>
<html>
<head>
    <title>Patient List</title>



</head>
<body >

<form runat="server">

    To sort click the appropriate column header<br /><br />
    <asp:GridView ID="gdPatientID"
     AllowSorting="true"
     AllowPaging="true"
     AutoGenerateEditButton="true"
     AutoGenerateDeleteButton="true"
     DataKeyNames="PatientID"
     CellPadding="5"
     HeaderStyle-BackColor="#BE7103"
     HeaderStyle-Font-Size="X-Small"
     runat="server"
     DataSourceID="SqlDataSource1"
     AutoGenerateColumns="false">
        <Columns>
            <asp:BoundField ReadOnly="true" HeaderText="Patient Number" DataField="PatientID" SortExpression="PatientID" />
            <asp:BoundField HeaderText="First Name" DataField="FirstName" SortExpression="FirstName" />
            <asp:BoundField HeaderText="Last Name" DataField="LastName" SortExpression="LastName" />

        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
        SelectCommand="SELECT PatientID, FirstName, LastName FROM Patient Where FacilityID = userID"
        UpdateCommand="UPDATE Patient SET LastName = @LastName Where FacilityID = @FacilityID"
        DeleteCommand="Delete From Patient Where FacilityID=@FacilityID"
        ConnectionString="<%$ ConnectionStrings:User %>" />
    </form>

    </body>
</html>

The error I'm getting is

Invalid column name 'userID'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Invalid column name 'userID'.

If there is a easier way to accomplish this I really need the assistance.

Thanks



All times are GMT -4. The time now is 09:31 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.