且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法将参数值从Double转换为DateTime。

更新时间:2023-02-04 09:14:22

首先,使用AddWithValue - 它使它很多更清楚:

First off, use AddWithValue - it makes it a lot clearer:
parameters.AddWithValue("@InvoiceNo", 0);
parameters.AddWithValue("@H",DropDownh.SelectedValue.ToString().Replace("'", "''"));
parameters.AddWithValue("@value", Double.Parse(txtvalue.Text.Trim()));
...

然后,不要将DateTime转换为字符串:

Then, don't convert DateTime to string:

parameters.AddWithValue("@InvoiceDatetime", DateTime.Now);

假设您的数据库列是正确的,它应该全部工作正常。

And assuming your database columns are right, it should all work ok.


我认为在你的double变量中有某种方式出现null,如果它那么它就不会转换为datetime。这是我的假设
I think there is null coming somehow in your double variable ,if it so then it will not convert into datetime. It is my assumption only