john kanyora

john kanyora

  • NA
  • 242
  • 46.5k

stored procedure to retrieve data from radiobutton to table

Feb 27 2018 2:47 AM
kindly help on how i can implement a stored procedure on the code behind that once i use my radiobutton it loads the data to the table sms_outbox.
 
i have created the stored procedure below but once i implement in the code behind it does not work.this is my code behind;
 
protected void radioButton1_CheckedChanged(Object sender, EventArgs e)
{
SqlCommand SqlCmd = new SqlCommand();
SqlCmd.CommandText = "[enterprise].[send_sms]";
SqlCmd.CommandType = CommandType.StoredProcedure;
SqlCmd.Parameters.Add("@CompanyID", SqlDbType.NVarChar).Value = CompanyID;
SqlCmd.Parameters.Add("@BranchID", SqlDbType.NVarChar).Value = BranchID;
SqlCmd.Parameters.Add("@DepartmentID", SqlDbType.NVarChar).Value = DepartmentID;
SqlCmd.Parameters.Add("@EmployeeMobilePhone", SqlDbType.NVarChar).Value = EmployeeMobilePhone;
SqlCmd.Parameters.Add("@VendorPhone", SqlDbType.NVarChar).Value = VendorPhone;
SqlCmd.Parameters.Add("@PatientCellPhone", SqlDbType.NVarChar).Value = PatientCellPhone;
}
 
this is my stored procedure
 
Create PROCEDURE [enterprise].[send_sms]
(
@CompanyID NVARCHAR(72),
@BranchID NVARCHAR(36),
@DepartmentID NVARCHAR(36),
@Value nvarchar(36)=''
)
AS
DECLARE @EmployeeName nvarchar(36)
DECLARE @EmployeeMobilePhone nvarchar(36)
DECLARE @VendorName nvarchar(36)
DECLARE @VendorPhone nvarchar(36)
DECLARE @PatientName nvarchar(36)
DECLARE @PatientCellPhone nvarchar(36)
BEGIN
IF @Value='Patients'
BEGIN
insert into sms_outbox(CompanyID,BranchID,DepartmentID,Recipient)
select CompanyID,BranchID,DepartmentID,PatientCellPhone from CustomerInformation
END
ELSE IF @Value='Suppliers'
BEGIN
insert into sms_outbox(CompanyID,BranchID,DepartmentID,Recipient)
select CompanyID,BranchID,DepartmentID,VendorPhone from VendorInformation
END
 
this is my aspx page with the radiobutton defined
 
<asp:RadioButtonList ID="Radiobuttonlist1" OnCheckedChange="Radiobuttonlist1_CheckedChange" runat="server">
<asp:ListItem Text="Patients" Value="Patients"></asp:ListItem>
<asp:ListItem Text="Suppliers" Value="Suppliers"></asp:ListItem>
<asp:ListItem Text="Employees" Value="Employees"></asp:ListItem>
</asp:RadioButtonList>

Answers (9)