从数据库转换日期时间格式的问题 [英] problem converting datetime format from database

查看:155
本文介绍了从数据库转换日期时间格式的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从表中收到一些值,将它绑定到一个组合框,现在,由于从数据库接收的数据中的日期时间格式,将它转换为表格式是一个问题。

ProcessingTB processvalue =(ProcessingTB)cmbTranscationdate.SelectedValue;

I receive some values from table, bind it to a combobox, now, to convert it to the table format is a poblem because of the datetime format in the data received from the database.
ProcessingTB processvalue=(ProcessingTB)cmbTranscationdate.SelectedValue;

推荐答案

ProcessingTB value =(ProcessingTB)cmbTranscationDate.SelectedValue;



错误消息:

System.InvalidCastException未被用户代码处理

消息=无法转换类型为'<> f__AnonymousType1`2的对象[System.DateTime, System.Int32]'键入'IntSalCom.ProcessingTB'。

Source = IntSalCom

StackTrace:

at IntSalCom.ItemList.cmbTranscationDate_SelectedIndexChanged(Object发件人,EventArgs e)在C:\ Users \DOvercomer \Documents\Visual Studio 2010 \Projects\IntSalCom\IntSalCom\ItemList.cs:第115行

在System。 Windows.Forms.ComboBox .OnSelectedIndexChanged(EventArgs e)

at System.Windows.Forms.ComboBox.set_SelectedIndex(Int32 value)

at System.Windows.Forms.ComboBox.RefreshItems()


在System.Windows.Forms.ListControl.SetDataConnection(对象newDataSource,BindingMemberInfo newDisplayMember,布尔力)

在System.Windows.Forms.ListControl.set_DataSource(对象值)

InnerException:
ProcessingTB value = (ProcessingTB)cmbTranscationDate.SelectedValue;

Error Message:
System.InvalidCastException was unhandled by user code
Message=Unable to cast object of type '<>f__AnonymousType1`2[System.DateTime,System.Int32]' to type 'IntSalCom.ProcessingTB'.
Source=IntSalCom
StackTrace:
at IntSalCom.ItemList.cmbTranscationDate_SelectedIndexChanged(Object sender, EventArgs e) in C:\Users\DOvercomer\Documents\Visual Studio 2010\Projects\IntSalCom\IntSalCom\ItemList.cs:line 115
at System.Windows.Forms.ComboBox.OnSelectedIndexChanged(EventArgs e)
at System.Windows.Forms.ComboBox.set_SelectedIndex(Int32 value)
at System.Windows.Forms.ComboBox.RefreshItems()
at System.Windows.Forms.ComboBox.OnDataSourceChanged(EventArgs e)
at System.Windows.Forms.ListControl.SetDataConnection(Object newDataSource, BindingMemberInfo newDisplayMember, Boolean force)
at System.Windows.Forms.ListControl.set_DataSource(Object value)
InnerException:


这篇关于从数据库转换日期时间格式的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆