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 ChaubeyRank #1,073 · 1.8K reputationPosted Feb 27, 2018, 10:43 PM EST
john kanyoraRank #6,677 · 259 reputationPosted Feb 26, 2018, 11:23 PM EST
Sundaram SubramanianRank #150 · 15.2K reputationPosted Feb 26, 2018, 10:22 PM EST
Rajneesh ChaubeyRank #1,073 · 1.8K reputationPosted Feb 27, 2018, 4:33 AM EST
john kanyoraRank #6,677 · 259 reputationPosted Feb 27, 2018, 9:38 PM EST
{
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 ChaubeyRank #1,073 · 1.8K reputationPosted Feb 27, 2018, 10:11 PM EST
john kanyoraRank #6,677 · 259 reputationPosted Feb 27, 2018, 10:32 PM EST
john kanyoraRank #6,677 · 259 reputationPosted Feb 27, 2018, 11:11 PM EST
john kanyoraRank #6,677 · 259 reputationPosted Feb 28, 2018, 12:27 AM EST
(
@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();
}}}
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts