使用c#将Sybase日期转换为Sql Datetime. [英] Converting Sybase date to Sql Datetime using c#.
问题描述
我正在寻找将Sybase日期字段映射到sql服务器日期字段的解决方案.
我正在使用biztalk映射器来映射两个架构.输入模式将数据从sybase接收并输出到
sql server2008.尝试在地图中映射日期字段.使用c#脚本functoid从sybase获取日期字段并将其映射到sql server的问题.脚本是
I am looking for a solution in mapping Sybase date field to sql server date field.
I am using biztalk mapper to map two schemas. Input schema takes data from sybase and outputs in to
sql server 2008. Trying to map the date fields in the map. The issue to take the date field from sybase and map it to sql server using scripting functoid with c#. The script is
pubilc string getdate(Datetime mydate)
{
string sqldate = mydate.ToString();
DateTime dt = DateTime.Parse(sqldate);
sqldate = dt.ToString();
return sqldate;
}
在这里,我收到一条错误消息,提示无法将字符串转换为DateTime.
在此问题上有任何帮助.
谢谢
Moh
Here I am getting an error saying that a string cannot be converted to DateTime.
Any help on this issue.
Thanks
Moh
推荐答案
调试代码以查看您是否实际上以正确的DateTime
格式获取字符串.您可能想尝试使用TryParse()
代替Parse().
Debug your code to see if you are actually getting the string in properDateTime
format. You might want to try usingTryParse()
instead ofParse().
这篇关于使用c#将Sybase日期转换为Sql Datetime.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!