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

问题描述

这是我编码的

This i coded

dataGridView1.Rows.Clear();
            connect.ConnectionString = Tool.getStringDB(set.dbname, set.versionaccess);
            connect.Open();


            cmd.Connection = connect;
            cmd.CommandText = "SELECT * From InvoiceInformation WHERE Order_date between '" + startdate + "' and '"+enddate+"'";

            OleDbDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                dataGridView1.Rows.Add();

                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["Invoice_no"].Value = reader[0].ToString();
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["Purchase_ProductID"].Value = reader[1].ToString();
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["Purchase_ProductName"].Value = reader[2].ToString();
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["Purchase_Amout"].Value = reader[3].ToString();
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["Purchase_TotalPay"].Value = reader[4].ToString();
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["Order_date"].Value = reader[5].ToString();
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["Customer_name"].Value = reader[6].ToString();
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["Address"].Value = reader[7].ToString();
            }
            connect.Close();



startdate和enddate = datetimepicker



i得到此错误

标准表达式中的数据类型不匹配。

in

OleDbDataReader reader = cmd.ExecuteReader();


startdate and enddate = datetimepicker

i got this error
Data type mismatch in criteria expression.
in
OleDbDataReader reader = cmd.ExecuteReader();

推荐答案

DateTime myDate = DateTime.ParseExact(reader[5].ToString(), "yyyy-MM-dd HH:mm:ss,fff", System.Globalization.CultureInfo.InvariantCulture)

 dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["Order_date"].Value=myDate;


这篇关于OlddbDataReader读取datetimepicker?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 09:26