[英]inserting millisecond into mysql from c#
I am trying to insert millisecond into data type of datetime(6) in MySQL using c#. 我试图使用c#在MySQL中将毫秒插入到datetime(6)的数据类型中。
here is my code: 这是我的代码:
MySqlCommand myCommand4 = new MySqlCommand("Insert into Test_OrderRecord values('" + OrderID + "','" + customerCode + "','" + customer + "','" + TelComboBox.Text + "','" + LicenseComboBox.Text + "','" +
DriverComboBox.Text + "','" + AddressComboBox.Text + "','" + LocationTypeComboBox.Text + "','" + PickupComboBox.Text + "','" + CustomerTypeLabel.Text + "','" +
Convert.ToDecimal(TotalPriceLabel.Text) + "','" + status + "','" + note + "','" + sandReceiptNo + "','" + createtiming + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')", myConnection);
myCommand4.ExecuteNonQuery();
the createtiming
is created with 该createtiming
与创建
createtiming = OrderDateTimePicker.Value.ToString("yyyy-MM-dd HH:mm:ss:ffffff");
I have read the value of createtiming
before it inserts into MySQL, and it does contain milliseconds, however, when I do 我已经在插入到MySQL之前读取了createtiming
的值,并且它确实包含毫秒,但是,当我这样做时
SELECT * FROM SaveFundDevelopmentDB.Test_OrderDetails
on MySQL, I only see time like 在MySQL上,我只看到时间
2015-08-27 15:33:04.000000
While the time should be like 2015-08-27 15:33:04.123456 something like this. 虽然时间应该像2015-08-27 15:33:04.123456这样的东西。
I am trying to Order the table by using this createtiming
to the very millisecond. 我试图通过使用这个创建到非常毫秒的顺序来createtiming
表。
How should I get this done? 我该怎么办呢?
check out this tutorial with parameterized queries. 使用参数化查询查看本教程。
1. Ceate a command object : 1. Ceate命令对象:
MySqlCommand cmd = new MySqlCommand();
Define a parameter : 定义参数:
MySqlParameter dt = new MySqlParameter(); dt.ParameterName = "@createTiming"; dt.MySqlDbType = MySqlDbType.DateTime;<br> dt.Value = "2015-08-27 15:33:04.123456";<br> cmd.Parameters.Add(dt);
Call cmd.ExecuteNonQuery(); 调用cmd.ExecuteNonQuery();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.