将数据库值与文本框值进行比较时出现问 [英] Problem comparing database values with textbox values

查看:46
本文介绍了将数据库值与文本框值进行比较时出现问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

展开 | 选择 | Wrap | 行号

推荐答案

代码标签是必需的。


请阅读并遵循发布指南

调节器


也许你从数据库获得的值有空格或什么。
Code tags are a requirement.

Please read and follow the Posting Guidelines.

MODERATOR

Perhaps the value you are getting from the DB has spaces or something.



SqlConnection cn = new SqlConnection();

cn.ConnectionString =" Data Sou rce =;数据库=; uid =; pwd =" ;;

cn.Open();

string sqt ="从跟踪中选择状态no = @ o" ;;

SqlCommand cmr = new SqlCommand(sqt,cn);

cmr.Parameters.AddWithValue(" @ o",Convert.ToInt32(textBox1.Text)) ;

status = Convert.ToString(cmr.ExecuteScalar());
SqlConnection cn = new SqlConnection();
cn.ConnectionString = "Data Source= ;Database= ;uid= ;pwd= ";
cn.Open();
string sqt = "Select status from tracking where no=@o";
SqlCommand cmr = new SqlCommand(sqt, cn);
cmr.Parameters.AddWithValue("@o", Convert.ToInt32(textBox1.Text));
status = Convert.ToString(cmr.ExecuteScalar());



看不出任何问题,但你的疑问。尝试进行一些直接查询以检查状态数据以查看是否存在任何问题并尝试不同类型的数据执行。如下所示,我将使用DataReader获取数据。

Couldn''t see any problems but your queries. Try to make some straight queries to check status data to see if there is any problem and try different type of data execution. Like below, I''ll use DataReader to get data.

展开 | 选择 | Wrap | 行号



除了你的疑问之外,看不到任何问题。尝试进行一些直接查询以检查状态数据以查看是否存在任何问题并尝试不同类型的数据执行。如下所示,我将使用DataReader获取数据。

Couldn''t see any problems but your queries. Try to make some straight queries to check status data to see if there is any problem and try different type of data execution. Like below, I''ll use DataReader to get data.

展开 | 选择 | Wrap | 行号


这篇关于将数据库值与文本框值进行比较时出现问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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