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
Rajneesh ChaubeyPosted Feb 28, 2018, 3:43 AM
john kanyoraPosted Feb 28, 2018, 5:27 AM
(
@Value nvarchar(36)
)
AS
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
ELSE IF @Value='Employees'
BEGIN
insert into sms_outbox(CompanyID,BranchID,DepartmentID,Recipient)
select CompanyID,BranchID,DepartmentID,EmployeeMobilePhone from PayrollEmployees
END
END
{
string Value = Radiobuttonlist1.SelectedItem.Value.ToString();
string constr = TraceBizCommon.Configuration.ConfigSettings.ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
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("@Value", SqlDbType.NVarChar).Value = this.Value;
SqlCmd.Connection = con;
con.Open();
con.Close();
}}}
john kanyoraPosted Feb 28, 2018, 4:11 AM
john kanyoraPosted Feb 28, 2018, 3:32 AM
Rajneesh ChaubeyPosted Feb 28, 2018, 3:11 AM
john kanyoraPosted Feb 28, 2018, 2:38 AM
{
string value = Radiobuttonlist1.SelectedItem.Value.ToString();
string constr = TraceBizCommon.Configuration.ConfigSettings.ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
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;
SqlCmd.Parameters.Add("@Value", SqlDbType.NVarChar).Value = Value;
SqlCmd.Connection = con;
con.Open();
con.Close();
}
}
}
Rajneesh ChaubeyPosted Feb 27, 2018, 9:33 AM
john kanyoraPosted Feb 27, 2018, 4:23 AM
Sundaram SubramanianPosted Feb 27, 2018, 3:22 AM