Click here to Skip to main content
15,911,132 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Greetings I'm using C# with sql server and i have this code with stored procedure which run perfectly with me but with other Run ok but that stored procedure doesn't work on there pc I don't really know why and here my code

C#
private void button6_Click(object sender, EventArgs e)
        {
            Password frm = new Password();
            frm.ShowDialog();

            if (password_text == true)
            {
                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    DataGridViewCheckBoxCell check = row.Cells[12] as DataGridViewCheckBoxCell;
                    if (check.Value != null)
                    {
                        try
                        {
                            //to check if not checked:
                            if (Convert.ToBoolean(check.Value) == true)
                            {
                                SelectedProcced(Convert.ToDateTime(row.Cells[1].Value), row.Cells[2].Value.ToString(), DateTime.Now.ToString("MM/dd/yyy"),_application.Shift.StaffId.ToString());
                            }
                        }
                        catch
                        {

                        }
                    }
                }
            }
            GetDataRP();
        } 



And here my method which run stored procedure which not working on other pc

C#
public void SelectedProcced(DateTime? createdate, string itemid, string ReviewDate, string STAFFID)
        {
            connection.Open();
            SqlParameter[] param = new SqlParameter[4];
            param[0] = new SqlParameter("@createdate", SqlDbType.DateTime);
            param[0].Value = createdate;

            param[1] = new SqlParameter("@itemid", SqlDbType.NVarChar, 200);
            param[1].Value = itemid;

            param[2] = new SqlParameter("@ReviewDate", SqlDbType.NVarChar, 200);
            param[2].Value = ReviewDate;

            param[3] = new SqlParameter("@STAFFID", SqlDbType.NVarChar, 200);
            param[3].Value = STAFFID;

            ExecuteCommand("SelectedProcced", param);
            connection.Close();
        } 



and here my stored procedure


SQL
Create  PROCEDURE [dbo].[SelectedProcced]
@createdate datetime, @itemid NVarChar(200),@ReviewDate NVarChar(200),@STAFFID NVarChar(200)
as
UPDATE TOP (1) ax.RETAILTRANSACTIONSALESTRANS2 
 SET [Process]=1 
WHERE ([ITEMID]=@itemid or [BARCODE]=@itemid)


What I have tried:

i'm even try to change name of my stored procedure but the problem is this only method not working in other pc but other methods working perfectly fine with my pc and other pc
the stored procedure is already install with other PC DB
Posted
Comments
Richard Deeming 14-Nov-19 8:12am    
What does not working mean? Do you get an error message?
mohammed mqi 14-Nov-19 8:14am    
i have no error message but this funcation SelectedProcced won't apply on sql
Richard Deeming 14-Nov-19 8:16am    
It's probably because you have an empty catch block, which is swallowing the exception.

Change that to catch the exception and display or log the error.
mohammed mqi 14-Nov-19 8:24am    
the problem is it's working fine with me but my friend pc not apply the stored procedure even not give me any error's i also enter same data
ZurdoDev 14-Nov-19 8:29am    
You are just repeating yourself. What Richard was saying is that the code is probably generating an error on the other PC but because you have an empty catch block you'll never know it.

Fix that first.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900