Thread: caching
View Single Post
  #1 (permalink)  
Old February 27th, 2007, 05:00 PM
jezywrap jezywrap is offline
Authorized User
Join Date: Dec 2005
Location: , , .
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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"));


    <title>Patient List</title>

<body >

<form runat="server">

    To sort click the appropriate column header<br /><br />
    <asp:GridView ID="gdPatientID"
            <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" />

    <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 %>" />


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.