从数据库中检索数据后逻辑不起作用 [英] logic not working after retrieving data from database

查看:82
本文介绍了从数据库中检索数据后逻辑不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

private void textBox10_Click(object sender, EventArgs e)
        {
            int a = 0, b = 0, c = 0;

            if (!int.TryParse(textBox8.Text,
                                System.Globalization.NumberStyles.Integer,
                                System.Globalization.CultureInfo.CurrentUICulture,
                                out a))
            {
                MessageBox.Show("u need to enter value");
            }
            else if (!int.TryParse(textBox9.Text,
                                    System.Globalization.NumberStyles.Integer,
                                    System.Globalization.CultureInfo.CurrentUICulture,
                                    out b) || (b > a))
            {
                MessageBox.Show("u entered greater value");
            }
            else
            {
                c = a - b;
                textBox10.Text = c.ToString(
                    System.Globalization.CultureInfo.CurrentUICulture);
            }

               
        }







while插入数据..这个代码正确地执行减法,然后我只是使用搜索查询从DB中检索添加数据..现在textbox8,9,10将从DB中获取数据,如12,8,4 ...现在,如果我改变textbox9和textbox8的值,然后单击textbox10,它需要执行减法(textbox10的click事件),但它在第一个if语句显示时不执行简单的MessageBox ...

为什么会发生这种情况




while inserting data..this code performing subtraction correctly, then i just retrieved "added" data from DB using search query.. now textbox8,9,10 will have fetched data from DB like 12,8,4... now if i change the value of textbox9 and textbox8 and click textbox10 it need to perform subtraction(click event for textbox10) but its not performing simply MessageBox in first if statement displaying...
why this happening

推荐答案

这不是我们可以从这里解决的问题 - 你需要更仔细地看看它为什么没有通过第一次TryParse操作。



在if语句上放一个断点,然后用调试器查看 textBox8.Text 中的确切内容 - 可能有选项卡或其他难以看到的角色。



它也可能值得展示用于加载文本框的代码,如果用调试器看不到任何明显的东西。
That''s not really somethign we can fix for you from here - you need to look more closely at why it''s failing the first TryParse operation.

Put a breakpoint on the if statement, and look at exactly what is in the textBox8.Text with the debugger - there may be a tab or other character which is difficult to see.

It might also be worth showing the code you use to load the textbox if you can''t see anything obvious with the debugger.


这篇关于从数据库中检索数据后逻辑不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆