I am trying to delete multiple records from WinForms. Created one Delete Stored Procedure which will delete multiple records and after deleting it will reorder index wise like 1,2,3 and so on.
and providing 4 input parameters in SP which come from Application.
In Code
I created one WCF Delete Method with mentioning the SP name along with mentioning 4 parameters which is used in SP .
and the same method I am trying to bind with delete in Client Side.
But while debugging all parameters values are coming null. What and where I need to fix it .Please help me
What I have tried:
1.Parameters in SP
CREATE PROCEDURE [DeleteRecords]
@TBL_ID varchar(2000),
@ACCT_ID int,
@SEQ_NUM Char (4),
@CMNT_TXT varchar (100)
2.WCFMethod mentioned
public void DeleteCollPolicies(string strCollPolicyIds ,int CollAcctID,string Term_Seq_Num, string Iteration_Cmnt_Text)
{
SqlParameter[] sqlParameter = new SqlParameter[4];
sqlParameter[0] = new SqlParameter("@TBL_ID", SqlDbType.VarChar, 2000, ParameterDirection.Input, true, 0, 0, "TBL_POL_COLL_AGMT_DTLS_ID", DataRowVersion.Current, strCollPolicyIds);
sqlParameter[1] = new SqlParameter("@COLL_ID", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "COLL_ID", DataRowVersion.Current, CollAcctID);
sqlParameter[2] = new SqlParameter("@SEQ_NUM", SqlDbType.Char, 4, ParameterDirection.Input, true, 10, 0, "SEQ_NUM", DataRowVersion.Current, Term_Seq_Num);
sqlParameter[3] = new SqlParameter("@CMNT_TXT", SqlDbType.VarChar, 100, ParameterDirection.Input, true, 10, 0, "CMNT_TXT ", DataRowVersion.Current, Iteration_Cmnt_Text);
SqlHelper.ExecuteNonQuery(strConnStr, CommandType.StoredProcedure, "DeleteRecords", sqlParameter);
//return listdata;
// return Convert.ToInt32(sqlParameter[4].Value);
}
3.Finally the Delete method with binding WCF method
private void btnDelete_Click(object sender, EventArgs e)
{
string strCollPolicyIds = string.Empty;
string Seq_Num = string.Empty;
string Cmnt_Text = string.Empty;
int cctID = ThisWorkbook.AccountId ;
int total = dataGridView1.Rows.Cast<datagridviewrow>().Where(p => Convert.ToBoolean(p.Cells["chkbox"].Value) == true).Count();
if(total > 0)
{
string message = $"Are you sure want to delete {total} row?";
if(total>=1)
{
message = $"Are you sure want to delete {total}rows";
if (MessageBox.Show(message, "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
for(int i = 0; i< dataGridView1.RowCount; i++)
{
// "1,2,3"
DataGridViewRow row = dataGridView1.Rows[i];
if(Convert.ToBoolean(row.Cells["chkbox"].Value)== true)
{
ServClient.DeleteCollPolicies(strCollPolicyIds, AcctID, Seq_Num, Cmnt_Text);
}