Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. CREATE TABLE [dbo].[Prescriptions] (
  2. [Prescription_ID] INT IDENTITY (1, 1) NOT NULL,
  3. [Doctor_UserName] NVARCHAR (50) NOT NULL,
  4. [Patient_UserName] NVARCHAR (50) NOT NULL,
  5. [Drug_ID] INT NOT NULL,
  6. PRIMARY KEY CLUSTERED ([Prescription_ID] ASC)
  7. );
  8.  
  9. CREATE PROCEDURE [dbo].[AddPrescription]
  10. @doctor nvarchar(50),
  11. @patient nvarchar(50),
  12. @drug nvarchar(MAX)
  13. AS
  14. insert into dbo.Prescriptions (Doctor_UserName,Patient_UserName,Drug_ID)
  15. Select @doctor, @patient, d.Drug_ID
  16. from dbo.Drug as d
  17. where d.Trade_Name = @drug
  18.  
  19. <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:DefaultConnection %>" SelectCommand="AddPrescription" SelectCommandType="StoredProcedure">
  20. <SelectParameters>
  21. <asp:Parameter Name="doctor" Type="String" />
  22. <asp:ControlParameter ControlID="PatientDropDown" Name="patient" PropertyName="SelectedValue" Type="String" />
  23. <asp:ControlParameter ControlID="PrescriptionDropDown" Name="drug" PropertyName="SelectedValue" Type="String" />
  24. </SelectParameters>
  25. </asp:SqlDataSource>
  26.  
  27. protected void CreatePrescriptionBtn_Click(object sender, EventArgs e)
  28. {
  29. SqlDataSource3.SelectParameters["doctor"].DefaultValue = System.Web.HttpContext.Current.User.Identity.Name.ToString();
  30. SqlDataSource3.DataBind();
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement