Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何将datetime值存储在本地datetime变量中?_C#_Asp.net_Sql Server - Fatal编程技术网

C# 如何将datetime值存储在本地datetime变量中?

C# 如何将datetime值存储在本地datetime变量中?,c#,asp.net,sql-server,C#,Asp.net,Sql Server,我在to会话中存储了一些值。并使用where子句检索一些列datetime值,并使用此session值。 代码: 这里是第三行的生成错误 Error: string can not be explicitely convert into system.Datetime. 所以请给我确切的解决方案请…您需要将GetScalarValue返回的字符串解析为DateTime对象: DateTime Currentdate = default(DateTime); Session["d_id"] =

我在to
会话
中存储了一些值。并使用where子句检索一些列
datetime
值,并使用此
session
值。 代码:

这里是第三行的生成错误

Error: string can not be explicitely convert into system.Datetime.

所以请给我确切的解决方案请…

您需要将GetScalarValue返回的字符串解析为DateTime对象:

DateTime Currentdate = default(DateTime);
Session["d_id"] = dt.Rows[0]["d_id"];
var dtStr = objdl.GetScalerValue("select IsNull(Max(LoginDate),GETDATE()) from q_logintrack_panel where Id= '" + Session["d_id"].ToString() + "'");
Currentdate = DateTime.Parse(dtStr);

您需要将GetScalarValue返回的字符串解析为DateTime对象:

DateTime Currentdate = default(DateTime);
Session["d_id"] = dt.Rows[0]["d_id"];
var dtStr = objdl.GetScalerValue("select IsNull(Max(LoginDate),GETDATE()) from q_logintrack_panel where Id= '" + Session["d_id"].ToString() + "'");
Currentdate = DateTime.Parse(dtStr);

您需要将GetScalarValue返回的字符串解析为DateTime对象:

DateTime Currentdate = default(DateTime);
Session["d_id"] = dt.Rows[0]["d_id"];
var dtStr = objdl.GetScalerValue("select IsNull(Max(LoginDate),GETDATE()) from q_logintrack_panel where Id= '" + Session["d_id"].ToString() + "'");
Currentdate = DateTime.Parse(dtStr);

您需要将GetScalarValue返回的字符串解析为DateTime对象:

DateTime Currentdate = default(DateTime);
Session["d_id"] = dt.Rows[0]["d_id"];
var dtStr = objdl.GetScalerValue("select IsNull(Max(LoginDate),GETDATE()) from q_logintrack_panel where Id= '" + Session["d_id"].ToString() + "'");
Currentdate = DateTime.Parse(dtStr);

GetScalerValue方法返回一个字符串,但应该返回一个DateTime。您可以先将返回值分配给字符串,然后使用DateTime.Parse获取DateTime类型。向我们展示GetScalerValue()返回的内容。GetScalerValue方法返回字符串,但应返回DateTime。您可以先将返回值分配给字符串,然后使用DateTime.Parse获取DateTime类型。向我们展示GetScalerValue()返回的内容。GetScalerValue方法返回字符串,但应返回DateTime。您可以先将返回值分配给字符串,然后使用DateTime.Parse获取DateTime类型。向我们展示GetScalerValue()返回的内容。GetScalerValue方法返回字符串,但应返回DateTime。您可以先将返回值分配给字符串,然后使用DateTime.Parse获取DateTime类型。向我们展示GetScalerValue()返回的内容。