0
private void update()


            Int64 sum = 0;
            sum = (!string.IsNullOrEmpty(Request.QueryString["Id"])) ? Int64.Parse(Request.QueryString["Id"]) : 0;

            if (sum != 0) - Here in Debug mode, i get this condition is false and equals 0
            {
                var context = new myDatabase();

                var s = context.myTableName.FirstOrDefault(c => c.Id == sum);

                if (s!= null && s.Id > 0)
                    {
                        if (!String.IsNullOrEmpty(myTextBoxId.Text))
                        {
                            MyUpdateMethod(sum,Decimal.Parse(myTextBoxId.Text));
                        }
                    }

                    else
                    {
                        if (!String.IsNullOrEmpty(myTextBoxId.Text))
                        {
                            MyInsertMethod(sum, Decimal.Parse(myTextBoxId.Text));
                        }

                    }

                    Dear Friends,

                    I just want a if else condition to update (in if) and insert (in else) my Database table. But Using above condition, my Table only get Inserted and updates doesn't work. What's wrong in my code. Assigning null to my variable is correct? Pls do your help for me.

                    Thanks in advance
3
Contributors
3
Replies
22
Views
4 Years
Discussion Span
Last Post by Anonymous3
0

If I unsertood well your issue, the sentence Request.QueryString["Id"] is returninng a null or empty string or a zero value.
Please, verify what is the real content of the requested string.

Hope this helps

0

Thank you friends for your replies. I just complicated myself. I has some issues in my Linq Select Query. Just i modified my column name and it worked.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.