Click here to Skip to main content
15,884,472 members
Home / Discussions / C#
   

C#

 
QuestionPlz Send Me The Simpler Answer to connect with SSIS And SSRS Both In any Version fo the Excell Pin
Member 889223723-Jan-17 23:45
Member 889223723-Jan-17 23:45 
GeneralRe: Plz Send Me The Simpler Answer to connect with SSIS And SSRS Both In any Version fo the Excell Pin
Richard MacCutchan24-Jan-17 0:42
mveRichard MacCutchan24-Jan-17 0:42 
Questionnumber converter Pin
ab_ayo23-Jan-17 1:51
ab_ayo23-Jan-17 1:51 
AnswerRe: number converter Pin
Richard MacCutchan23-Jan-17 2:07
mveRichard MacCutchan23-Jan-17 2:07 
AnswerRe: number converter Pin
Patrice T23-Jan-17 9:52
mvePatrice T23-Jan-17 9:52 
GeneralRe: number converter Pin
Ed E24-Jan-17 9:22
professionalEd E24-Jan-17 9:22 
AnswerRe: number converter Pin
palikhelsanjeeb25-Jan-17 21:55
palikhelsanjeeb25-Jan-17 21:55 
QuestionHow to save values in table in SQL without crashing when it is used by multiple users Pin
TarunKumarSusarapu22-Jan-17 21:49
professionalTarunKumarSusarapu22-Jan-17 21:49 
How to save values in SQL in two different columns in a table without crashing of the values in a network.

Ex: There are 20 users in my network.All wants to update one particular row at a time.
Here the crashing has been taken place.That means suppose I have taken one table in that many columns there.The user wants to update two columns a,b with their values at a time. when we click on update sometimes it swaps the data.

a=10,
b=20 i want to update 

but it updated like this a=20,b=10
sometimes it has been taken null value also.
Why does it happen?
 
If you explain how to solve this problem.It would be appreciated.


I have written this code in c# to save.But while users saving at a time one row.The swapping of column values saving taken place.

sqlstr = "Insert into invINVOICEDETAILS (comment_NAME30, PRODUCT_NO, PRODUCT_NAME, QTY, UOM, PRICE, ITEM1_NO, DISCOUNT_PC, AMOUNT, SC_NO, GL_CODE, PROJ_NO, Gp_NO, WH_NO, Sales_exempt,FACTOR," +
                            "Category, IMPORTED_FROM_NO, IMPORTED_FROM, GST_Amt, DISCOUNT_PC_2,Ref_No, GL_DESC, PRODUCT_NAME_LONG, CREATED_BY," +
                            "DATE_CREATED, Deleted, INV_NO,Transfer, TICK, ID, AC_NO, AC_NAME, ITEM10, invNo_user, AVERAGE_COST, LP_COST, STD_COST,QTY_UNFILLED,DATETIME,Batch_No," +
                            "Expiry_Date,PRINT_ITEM,QTY_BILLED,ITEM6_NO,ITEM7_NO,ITEM8_NO,IMPORT_KEY) values (@comment_NAME30,@PRODUCT_NO,@PRODUCT_NAME,@QTY,@UOM,@PRICE," +
                                     "@ITEM1_NO,@DISCOUNT_PC,@AMOUNT,@SC_NO,@GL_CODE,@PROJ_NO,@Gp_NO," +
                                     "@WH_NO,@Sales_exempt,@FACTOR,@Category,@IMPORTED_FROM_NO," +
                                     "@IMPORTED_FROM,@GST_Amt,@DISCOUNT_PC_2,@Ref_No,@GL_DESC," +
                                     "@PRODUCT_NAME_LONG, @CREATED_BY, @DATE_CREATED, @Deleted, @INV_NO," +
                                     "@Transfer,@TICK,@ID,@AC_NO,@AC_NAME,@ITEM10,@invNo_user,@AVERAGE_COST," +
                                     "@LP_COST,@STD_COST,@QTY_UNFILLED,@DATETIME,@Batch_No,@Expiry_Date," +
                                     "@PRINT_ITEM, @QTY_BILLED,@ITEM6_NO,@ITEM7_NO,@ITEM8_NO,@IMPORT_KEY)";

                            //  cfs.Audit_Log("Invoice", ddl_Inv.Text, txt_Custcode.Text, strpcode, strUom, Prodqty, true, false, false);
                            //sqlstr = "insert into invINVOICEDETAILS (" + sfield + ") values (" + sdata + ")";
                            //sqlstr = "insert into invINVOICEDETAILS()";
                        }
                        else
                        {
                            sdata += "PRODUCT_NAME_LONG=N'" + cfs.singlequotconver(strdesc) + "', UPDATED_BY ='" + uid.ToString() + "',DATE_UPDATED='" + cfs.sqldateconverion() + "',Deleted='False',invNo_user='" + ddl_Inv.Text + uid.ToString() + "',CREATED_BY='" + uid + "' ," +
                                     "Transfer='U',TICK='C',AC_NO='" + cfs.singlequotconver(txt_Custcode.Text) + "',AC_NAME=N'" + cfs.singlequotconver(txt_Cus_Name.Text) + "',QTY_BILLED=" + Prodqty + ",ITEM10='" + cfs.singlequotconver(LineNo) + "',AVERAGE_COST=(select distinct AVERAGE_COST from PRODUCT where PRODUCT_NO='" + strpcode + "'),LP_COST=(select distinct LP_COST from PRODUCT where PRODUCT_NO='" + strpcode + "'),STD_COST=(select distinct STD_COST from PRODUCT where PRODUCT_NO='" + strpcode + "'),QTY_UNFILLED='" + strqtyfilled + "',DATETIME='" + cfs.sqldateconverion(txt_trans_Date.Value) + "'";
                            try
                            {
                                if (row.Cells["no"].Value.ToString() == "1")
                                {
                                    sdata += ",PRINT_ITEM='GD',Batch_No='" + row.Cells["BATCH_CODE"].Value.ToString() + "',Expiry_Date='" + row.Cells["EXPIRY_DATE"].Value.ToString() + "'";
                                }

                            }
                            catch (Exception Ex) { }


                            if (ZeroQtySave)
                            {
                                try
                                {

                                    sdata += ",ITEM6_NO=" + cfs.IsNumber(row.Cells["Qty"].Value.ToString()) + ",ITEM7_NO='" + pri + "',ITEM8_NO='" + cfs.IsNumber(row.Cells["NetAmount"].Value.ToString()) + "' ";
                                }
                                catch (Exception Ex)
                                {
                                }
                            }
                            //Modified By Tarun on 24-11-2016 3/3 for the purpose of Invoice clashing
                            //" invd_Item1='" + cfs.singlequotconver(Txt_Item1.Text) + "',invd_Item2='" + cfs.singlequotconver(Txt_Item2.Text) + "',invd_Item3='" + cfs.singlequotconver(Txt_Item3.Text) + "', " +
                            //" invd_Item4='" + cfs.singlequotconver(Txt_Item4.Text) + "',invd_Item5='" + cfs.singlequotconver(Txt_Item5.Text) + "',invd_Item6='" + cfs.singlequotconver(Txt_Item6.Text) + "', " +
                            //" invd_Item7='" + cfs.singlequotconver(Txt_Item7.Text) + "',invd_Item8='" + cfs.singlequotconver(Txt_Item8.Text) + "',invd_Item9='" + cfs.singlequotconver(Txt_Item9.Text) + "'";
                            //sqlstr = "update invINVOICEDETAILS set " + sdata + " where LINE = " + strid;
                            sqlstr = "update invINVOICEDETAILS set comment_NAME30=@comment_NAME30," +
                                     "PRODUCT_NO=@PRODUCT_NO,PRODUCT_NAME=@PRODUCT_NAME,QTY=@QTY,UOM=@UOM,PRICE=@PRICE," +
                                     "ITEM1_NO=@ITEM1_NO,DISCOUNT_PC=@DISCOUNT_PC,AMOUNT=@AMOUNT,SC_NO=@SC_NO," +
                                     "GL_CODE=@GL_CODE,PROJ_NO=@PROJ_NO,Gp_NO=@Gp_NO,WH_NO=@WH_NO,Sales_exempt=@Sales_exempt,FACTOR=@FACTOR,GST_Amt=@GST_Amt,DISCOUNT_PC_2=@DISCOUNT_PC_2," +
                                     "PRODUCT_NAME_LONG=@PRODUCT_NAME_LONG,Category=@Category,IMPORTED_FROM_NO=@IMPORTED_FROM_NO,UPDATED_BY =@UPDATED_BY,DATE_UPDATED=@DATE_UPDATED," +
                                     "Deleted=@Deleted,CREATED_BY=@CREATED_BY ,Transfer=@Transfer,TICK=@TICK,AC_NO=@AC_NO," +
                                     "AC_NAME=@AC_NAME,QTY_BILLED=@QTY_BILLED,ITEM10=@ITEM10,invNo_user=@invNo_user,IMPORTED_FROM=@IMPORTED_FROM,AVERAGE_COST=@AVERAGE_COST,LP_COST=@LP_COST,STD_COST=@STD_COST," +
                                     "QTY_UNFILLED=@QTY_UNFILLED,DATETIME=@DATETIME,Batch_No=@Batch_No,Expiry_Date=@Expiry_Date,PRINT_ITEM=@PRINT_ITEM," +
                                     "ITEM6_NO=@ITEM6_NO,ITEM7_NO=@ITEM7_NO,ITEM8_NO=@ITEM8_NO,IMPORT_KEY=@IMPORT_KEY where LINE = @LINE";
                            //  cfs.Audit_Log("Invoice", ddl_Inv.Text, txt_Custcode.Text, strpcode, strUom, Prodqty, false, true, false);
                        }
                        cmdTemp.CommandText = sqlstr;
                        try
                        {
       cmdTemp.Parameters.AddWithValue("@comment_NAME30", ((object)row.Cells[0].Value) ?? DBNull.Value);
                            cmdTemp.Parameters.AddWithValue("PRODUCT_NO", ((object)row.Cells[1].Value) ?? DBNull.Value);
                            cmdTemp.Parameters.AddWithValue("@PRODUCT_NAME", ((object)row.Cells[2].Value) ?? DBNull.Value);
                            cmdTemp.Parameters.AddWithValue("@QTY", ((object)row.Cells[3].Value) ?? DBNull.Value);
                            cmdTemp.Parameters.AddWithValue("@UOM", ((object)row.Cells[4].Value) ?? DBNull.Value);
                            cmdTemp.Parameters.AddWithValue("@PRICE", ((object)row.Cells[5].Value) ?? DBNull.Value);
                            cmdTemp.Parameters.AddWithValue("@ITEM1_NO", ((object)row.Cells[6].Value) ?? DBNull.Value);
                            cmdTemp.Parameters.AddWithValue("@DISCOUNT_PC", ((object)row.Cells[7].Value) ?? DBNull.Value);
                            cmdTemp.Parameters.AddWithValue("@AMOUNT", ((object)row.Cells[8].Value) ?? DBNull.Value);
                            cmdTemp.Parameters.AddWithValue("@SC_NO", ((object)row.Cells[10].Value) ?? DBNull.Value);
                            cmdTemp.Parameters.AddWithValue("@GL_CODE", ((object)row.Cells[11].Value) ?? DBNull.Value);
                            cmdTemp.Parameters.AddWithValue("@PROJ_NO", ((object)row.Cells[12].Value) ?? DBNull.Value);
                            cmdTemp.Parameters.AddWithValue("@Gp_NO", ((object)row.Cells[13].Value) ?? DBNull.Value);
                            cmdTemp.Parameters.AddWithValue("@WH_NO", ((object)row.Cells[14].Value) ?? DBNull.Value);
                            cmdTemp.Parameters.AddWithValue("@Sales_exempt", ((object)row.Cells[15].Value) ?? DBNull.Value);
                            cmdTemp.Parameters.AddWithValue("@FACTOR", ((object)row.Cells[16].Value) ?? DBNull.Value);
                            cmdTemp.Parameters.AddWithValue("@Category", ((object)row.Cells[18].Value) ?? DBNull.Value);
                            cmdTemp.Parameters.AddWithValue("@IMPORTED_FROM_NO", ((object)row.Cells[19].Value) ?? DBNull.Value);
                            cmdTemp.Parameters.AddWithValue("@IMPORTED_FROM", ((object)row.Cells[20].Value) ?? DBNull.Value);
                            cmdTemp.Parameters.AddWithValue("@GST_Amt", ((object)row.Cells[23].Value) ?? DBNull.Value);
                            cmdTemp.Parameters.AddWithValue("@DISCOUNT_PC_2", ((object)row.Cells[24].Value) ?? DBNull.Value);
                            cmdTemp.Parameters.AddWithValue("@Ref_No", ((object)row.Cells[25].Value) ?? DBNull.Value);
                            cmdTemp.Parameters.AddWithValue("@GL_DESC", ((object)row.Cells[27].Value) ?? DBNull.Value);
                            cmdTemp.Parameters.AddWithValue("@PRODUCT_NAME_LONG", cfs.singlequotconver(strdesc));
                            cmdTemp.Parameters.AddWithValue("@CREATED_BY", uid.ToString());
                            cmdTemp.Parameters.AddWithValue("@DATE_CREATED", cfs.sqldateconverion());
                            cmdTemp.Parameters.AddWithValue("@Deleted", "False");
                            cmdTemp.Parameters.AddWithValue("@INV_NO", ddl_Inv.Text);
                            cmdTemp.Parameters.AddWithValue("@Transfer", "U");
                            cmdTemp.Parameters.AddWithValue("@TICK", "C");
                            cmdTemp.Parameters.AddWithValue("@ID", strInvId);
                            cmdTemp.Parameters.AddWithValue("@AC_NO", cfs.singlequotconver(txt_Custcode.Text));
                            cmdTemp.Parameters.AddWithValue("@AC_NAME", cfs.singlequotconver(txt_Cus_Name.Text));
                            cmdTemp.Parameters.AddWithValue("@ITEM10", cfs.singlequotconver(LineNo));
                            cmdTemp.Parameters.AddWithValue("@invNo_user", ddl_Inv.Text + uid.ToString());
                            cmdTemp.Parameters.AddWithValue("@AVERAGE_COST", cfs.get_data("select distinct AVERAGE_COST from PRODUCT where PRODUCT_NO='" + strpcode + "'"));
                            cmdTemp.Parameters.AddWithValue("@LP_COST", cfs.get_data("select distinct LP_COST from PRODUCT where PRODUCT_NO='" + strpcode + "'"));
                            cmdTemp.Parameters.AddWithValue("@STD_COST", cfs.get_data("select distinct STD_COST from PRODUCT where PRODUCT_NO='" + strpcode + "'"));
                            cmdTemp.Parameters.AddWithValue("@QTY_UNFILLED", strqtyfilled);
                            cmdTemp.Parameters.AddWithValue("@DATETIME", cfs.sqldateconverion(txt_trans_Date.Value));
                            cmdTemp.Parameters.AddWithValue("@Batch_No", batchno);
                            cmdTemp.Parameters.AddWithValue("@Expiry_Date", Expirydate);
                            cmdTemp.Parameters.AddWithValue("@PRINT_ITEM", printitem);
                            cmdTemp.Parameters.AddWithValue("@QTY_BILLED", Prodqty);
                            cmdTemp.Parameters.AddWithValue("@ITEM6_NO", Prodqty);
                            cmdTemp.Parameters.AddWithValue("@ITEM7_NO", pri);
                            cmdTemp.Parameters.AddWithValue("@ITEM8_NO", net);
                            cmdTemp.Parameters.AddWithValue("@IMPORT_KEY", ((object)row.Cells[21].Value) ?? DBNull.Value);
                            //MODIFICATION END 28DEC2016 1/1
                            if (isexisted == true)
                            {
                                cmdTemp.Parameters.AddWithValue("@LINE", strid);
                                cmdTemp.Parameters.AddWithValue("@UPDATED_BY", uid.ToString());
                                cmdTemp.Parameters.AddWithValue("@DATE_UPDATED", cfs.sqldateconverion());
                            }
                        }
                        catch (Exception EX) { }
Im

Tarun Kumar

AnswerRe: How to save values in table in SQL without crashing when it is used by multiple users Pin
Afzaal Ahmad Zeeshan22-Jan-17 23:43
professionalAfzaal Ahmad Zeeshan22-Jan-17 23:43 
GeneralRe: How to save values in table in SQL without crashing when it is used by multiple users Pin
TarunKumarSusarapu23-Jan-17 0:44
professionalTarunKumarSusarapu23-Jan-17 0:44 
GeneralRe: How to save values in table in SQL without crashing when it is used by multiple users Pin
Afzaal Ahmad Zeeshan23-Jan-17 1:08
professionalAfzaal Ahmad Zeeshan23-Jan-17 1:08 
AnswerRe: How to save values in table in SQL without crashing when it is used by multiple users Pin
Simon_Whale23-Jan-17 0:27
Simon_Whale23-Jan-17 0:27 
GeneralRe: How to save values in table in SQL without crashing when it is used by multiple users Pin
TarunKumarSusarapu23-Jan-17 0:45
professionalTarunKumarSusarapu23-Jan-17 0:45 
GeneralRe: How to save values in table in SQL without crashing when it is used by multiple users Pin
Pete O'Hanlon23-Jan-17 0:46
mvePete O'Hanlon23-Jan-17 0:46 
GeneralRe: How to save values in table in SQL without crashing when it is used by multiple users Pin
Simon_Whale23-Jan-17 0:47
Simon_Whale23-Jan-17 0:47 
GeneralRe: How to save values in table in SQL without crashing when it is used by multiple users Pin
TarunKumarSusarapu23-Jan-17 0:54
professionalTarunKumarSusarapu23-Jan-17 0:54 
SuggestionRe: How to save values in table in SQL without crashing when it is used by multiple users Pin
Richard Deeming23-Jan-17 3:17
mveRichard Deeming23-Jan-17 3:17 
GeneralRe: How to save values in table in SQL without crashing when it is used by multiple users Pin
TarunKumarSusarapu23-Jan-17 18:10
professionalTarunKumarSusarapu23-Jan-17 18:10 
GeneralRe: How to save values in table in SQL without crashing when it is used by multiple users Pin
TarunKumarSusarapu23-Jan-17 18:57
professionalTarunKumarSusarapu23-Jan-17 18:57 
GeneralRe: How to save values in table in SQL without crashing when it is used by multiple users Pin
Richard Deeming24-Jan-17 2:05
mveRichard Deeming24-Jan-17 2:05 
GeneralRe: How to save values in table in SQL without crashing when it is used by multiple users Pin
TarunKumarSusarapu24-Jan-17 0:24
professionalTarunKumarSusarapu24-Jan-17 0:24 
AnswerRe: How to save values in table in SQL without crashing when it is used by multiple users Pin
Gerry Schmitz23-Jan-17 8:39
mveGerry Schmitz23-Jan-17 8:39 
GeneralRe: How to save values in table in SQL without crashing when it is used by multiple users Pin
TarunKumarSusarapu23-Jan-17 18:13
professionalTarunKumarSusarapu23-Jan-17 18:13 
GeneralRe: How to save values in table in SQL without crashing when it is used by multiple users Pin
Gerry Schmitz23-Jan-17 19:07
mveGerry Schmitz23-Jan-17 19:07 
GeneralRe: How to save values in table in SQL without crashing when it is used by multiple users Pin
TarunKumarSusarapu24-Jan-17 0:52
professionalTarunKumarSusarapu24-Jan-17 0:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.