在条件表达式中获取数据类型不匹配

编程入门 行业动态 更新时间:2024-10-14 16:25:36
本文介绍了在条件表达式中获取数据类型不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

喜!! 如果任何一个字段与d / b中的记录匹配,此代码显示结果 但是我我得到例外...... ''标准表达式中的数据类型不匹配。''

DataTable dt = new DataTable(); string custname = cust_name_txt.Text.ToString(); Int32 chassi,engine; bool result = Int32 .TryParse(cust_chassi_no_txt.Text , out chassi); bool res2 = Int32 .TryParse(sales_engine_no_txt.Text, out 引擎); string month = sale_month_cmb.Text; OleDbDataAdapter da = new OleDbDataAdapter( select * from sales WHERE [Customer Name] =' + custname + 'OR [ Chassi Number] =' + chassi + '或[Engine Number] =' + engine + '或[销售月份] =' +月+ ',con); con.Open(); da.Fill(dt); // 条件表达式中的数据类型不匹配。发生在这里.. dataGridView1.DataSource = dt; con.Close();

D / B中的所有数据类型都是正确的。我正在使用MS Access进行数据库.. 有人可以帮助我解决这个异常...

解决方案

为你的错误提供更多结果一些相关主题可以帮助您找到代码中的瑕疵...... [已解决]标准表达式中的数据类型不匹配 [ ^ ] 条件表达式中的数据类型不匹配 [ ^ ] social.msdn.microsoft/Forums / en-US / csharplanguage / thread / e268f6d6-4507-408d-ab84-1f0b95324479 / [ ^ ]

if [销售月份] ] [发动机编号] [Chassi编号] 是整数字段...... 检查您是否传递了正确的值,例如如果 [销售月份] int 列,并且您传递''1''然后它会导致错误 你无法在int栏中传递 char 甚至 space 所以,你应该通过''1'' 快乐编码! :)

hi!! this code displays result if any one field matches with the records in d/b but i am getting an Exception... '' Data type mismatch in criteria expression.''

DataTable dt = new DataTable(); string custname = cust_name_txt.Text.ToString(); Int32 chassi, engine; bool result = Int32.TryParse(cust_chassi_no_txt.Text, out chassi); bool res2 = Int32.TryParse(sales_engine_no_txt.Text, out engine); string month = sale_month_cmb.Text; OleDbDataAdapter da = new OleDbDataAdapter("select * from sales WHERE [Customer Name] = '" + custname + "' OR [Chassi Number] = '" + chassi + "' OR [Engine Number] = '" + engine + "' OR [Month of Sale] = '" + month + "' ", con); con.Open(); da.Fill(dt); //Data type mismatch in criteria expression. occurs here.. dataGridView1.DataSource = dt; con.Close();

all the datatypes in D/B are proper.i am using MS Access for database.. can someone please help me with this exception...

解决方案

for more result to your error there is some related topics that can help you to find your foult in code.... [SOLVED] Data type mismatch in criteria expression[^] data type mismatch in criteria expression[^] social.msdn.microsoft/Forums/en-US/csharplanguage/thread/e268f6d6-4507-408d-ab84-1f0b95324479/[^]

if [Month of Sale] [Engine Number] [Chassi Number] are integer field... Check you are passing correct values e.g. if [Month of Sale] is int column and you are passing ''1 '' then it will cause error you can not pass char or even space in int column so, you should pass ''1'' Happy Coding! :)

更多推荐

在条件表达式中获取数据类型不匹配

本文发布于:2023-11-22 14:39:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1617842.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表达式   数据类型   不匹配   条件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!