I am creating a website that allows a patient to log in and see their own data. So far when they log in they are redirected to the user.aspx page and a session displays their username on a label from the Patient table( I have included the session information to help with the question) ... But I also want a table to display the patients corresponding medicine information:
The patient table (all tables are dummy data):
The medicine table:
The session after login is authenticated in login.aspx:
Public Function CheckUser(username As String, password As String) As Integer
Dim cmdstring As String = "SELECT * FROM Patient Where Username=@USERNAME AND Password=@PASSWORD"
Dim found = 0
Using conn As New SqlConnection("Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Laura\Final_proj\App_Data\surgerydb.mdf;Integrated Security=True;Connect Timeout=30")
Dim cmd = New SqlCommand(cmdstring, conn)
cmd.Parameters.Add("@USERNAME", SqlDbType.NChar).Value = username
cmd.Parameters.Add("@PASSWORD", SqlDbType.NChar).Value = password
conn.Open()
Dim reader = cmd.ExecuteReader()
While reader.Read()
Session("PatientId") = CInt(reader.Item("PatientId"))
Session("Username") = CStr(reader.Item("Username"))
found = CInt(reader.Item("PatientId"))
End While
reader.Close()
End Using
Return (found)
End Function
Label displaying user name in label in user.aspx:
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
Label1.Text = Session("Username")
End Sub
I have another table called prescription (link table) that has composite keys Patientid (from Patient table) and Medicine (from medicine table) - both foreign keys.
When the user logs in how can I get the Medicine table to display showing the user's corresponding medicine and the information from the table (Name, Purpose, Instructions) on user.aspx. Will I do this using a gridview from Toolbox?
Not sure where I am going wrong with the solution here




