附加信息:标准表达式中的数据类型不匹配。 C#Oledb connectioon [英] Additional information: Data type mismatch in criteria expression. C# Oledb connectioon

查看:68
本文介绍了附加信息:标准表达式中的数据类型不匹配。 C#Oledb connectioon的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在表PO中插入数据并抛出此异常, 这是我的代码,它有什么问题。

I want to insert data into table PO and throws this exception,  this is my code, whats wrong with it.

推荐答案

使用不同的方法添加允许您指定OleDb类型的参数而不是AddWithValue匹配目标表的数据类型。 AddWithValue的问题在于它从提供的.NET对象中推断出参数数据类型,并且
这些都是字符串,因为您使用的是Text属性值。在不知道DBMS或表结构的情况下我不能具体,但是一个例子是:

Instead of AddWithValue, use a different method to add parameters that allows you to specify OleDb types that match the data type of the target table. The problem with AddWithValue is that it infers the parameter data type from the provided .NET object and those are all strings here because you are using the Text property value. I can't be specific without knowing the DBMS or table structure but an example is:

   cmd.Parameters.Add("@TotalAmount", Decimal.Parse(textBox3.Text));

对于DateTimePicker控件,使用Value属性而不是Text属性,因为它将是强类型的。

In the case of the DateTimePicker control, use the Value property instead of the Text property as that will be strongly typed.


这篇关于附加信息:标准表达式中的数据类型不匹配。 C#Oledb connectioon的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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