用int提取数值 [英] Extracting numeric value with int

查看:89
本文介绍了用int提取数值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


希望这是正确的论坛。


我用C#编程[Win forms]和我在一定的输入日期之后,我一直在绞尽脑汁寻找正确的答案来提取我的信息。问题是,当我硬编码数字日期时,根本没有问题,所有请求的信息都正确显示。但是当我尝试将变量(参数)作为整数传递时,如下面的代码中所示,语法生成此错误没有给出一个或多个必需参数的值。


猜猜我想说的是什么是我缺少提取表格的正确代码。 MS Access是数据库,我正在使用C#。令人反感的整数是Start_Date。还有一个被阻止的代码,我在硬编码日期取得了成功。


感谢大家的帮助。

展开 | 选择 | Wrap | 行号

解决方案

看起来你有一些字符串创建问题。

在这一行:

OleDbDataAdapter Adapter_Zone = new OleDbDataAdapter(" SELECT * FROM [CLOSED_TABLE_ZONE] WHERE [TABLE_START_DATE]> = Start_Date",DB_Connection);

您实际上正在传递WORDStart_Date而不是Start_Date的值

感谢您的回复,但您或其他人知道我可以在哪里找到通过值传递的信息吗?


< blockquote>为什么你的Start_Date是一个整数?你知道如何获得20070423吗?从您的int号码?


例如如果Start_Date是一个DateTime变量,你可以轻松转换它:

展开 | 选择 | Wrap | 行号


Hi everyone,

Hopefully this is the right forum to use.

I am programming in C# [Win forms] and I''ve been racking my brain and searching for the right answer to extract my information according to after a certain input date. the problem is that when I hard-code the numeric date, there is no problem at all and all requested information is displayed correctly. But when I try to pass the variable (parameter) as an integer as in the code that follows, the syntax generates this error "No value given for one or more required parameters".

Guess what I''m trying to say is what is the right code that I am missing to extract the tables. MS Access is the db and I am using C#. The fustrating Integer is "Start_Date". There is also a blocked out code where I do have success with the hard-coded date.

Thank you all for any and all help.

Expand|Select|Wrap|Line Numbers

解决方案

Well it looks like you have some string creation issues.
In this line:
OleDbDataAdapter Adapter_Zone = new OleDbDataAdapter("SELECT * FROM [CLOSED_TABLE_ZONE] WHERE [TABLE_START_DATE] >= Start_Date", DB_Connection);
You are actually passing the WORD "Start_Date" instead of the value of Start_Date


Thank you for your reponse, but do you or anyone know where I can find the information to pass by value instead?


Why is your Start_Date an integer? Do you know how to get "20070423" from your int number?

E.g. if Start_Date was a DateTime variable, you could easily convert it:

Expand|Select|Wrap|Line Numbers


这篇关于用int提取数值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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