如何在Access表中使用Integer值选择查询? [英] How to have a Select Query with Integer value in Access Table?

查看:180
本文介绍了如何在Access表中使用Integer值选择查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用vs2010和访问表。我希望有一个带有整数值的Select Query。

但我收到错误为DataType Mismatch错误。有没有人可以给我一个正确的?

因为经过长时间的间隙Iam使用访问表...



我的代码

Hi, Iam using vs2010 and access table. I wish to have a Select Query with integer values.
But Iam receiving error as "DataType Mismatch" error. Does anybody can show me a correct one?
Because after long gap Iam using Access Table...

My Codes

SvINVNo = 0;
SvINVNo = Convert.ToInt32(richTextBox1.Text);
String SelctInvQury = "Select * from invoicemst where invoice_no= ' "&SvINVNo &" '";



谢谢


Thank you

推荐答案

请尝试以下方法:

Try the following :
String SelctInvQury = "Select * from invoicemst where invoice_no= " & SvINVNo ;


解决方案1告诉你的是不要在整数周围放置单引号。如果你这样做,它会被视为一个字符串。特别是因为你拥有它的方式是在整数的两边放置一个空格,然后将其作为字符串处理。
What Solution 1 was telling you is don't put single quotes around an integer. Then it is treated like a string if you do. Especially because the way you had it was also putting a space on either side of the integer and then treating that as a string.


String SelctInvQury = string.Format(select * from invoicemst where invoice_no = {0},SvINVNo);



找到答案
String SelctInvQury = string.Format("Select * from invoicemst where invoice_no= {0} ", SvINVNo);

Found the answer


这篇关于如何在Access表中使用Integer值选择查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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