本文介绍了日期时间问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我在我的SQL查询中将datetime.now.tostring()作为parMETER传递来检索Todays.的所有交易,但无法检索.
请帮帮我.

我的查询如下:
从bill_details中选择billno,net量,其中date =''"+ DateTime.Now.Tostring()+"'';


i am passing datetime.now.tostring() as parMETER IN MY SQL QUERY for retriving all the transaction of todays.but unable to retrive.
please help me.

my query like:
select billno,net amount from bill_details where date=''" +DateTime.Now.Tostring() + "'';

推荐答案

string sqlQuery = "SELECT billno, net_amount FROM bill_details WHERE date=@Date";

OleDbCommand sqlCommand = new OleDbCommand(sqlQuery, sqlConnection);
sqlCommand.Parameters.Add("@Date", OleDbType.VarChar).Value = DateTime.Now.ToString();

OleDbDataAdapter sqlAdapter = new OleDbDataAdapter(sqlCommand);

DataSet ds = new DataSet();
sqlAdapter.Fill(ds);



现在所有信息都应该在DataSet ds 中.并且可以作为DataSource绑定到DataGridView或以编程方式手动读取.



Now all information should be in DataSet ds. And can be bound as a DataSource to a DataGridView or be read manually progammetically.


这篇关于日期时间问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 13:18