体验:无法将类型为'System.Int32'的对象转换为类型为'System.String'的对象

时间:2019-12-19 08:22:26

标签: c# sql asp.net ado.net

嗨,我编写了以下代码,使用ADO.net从数据库中获取数据以在kendoGrid中显示 在我的网络服务中:

var result = new List<Timeline>();
            TimelineDB _TimelineDB = new TimelineDB();
            SPSecurity.RunWithElevatedPrivileges(delegate ()
            {
                _TimelineDB.loadTimeline_bulk(result, currentUserName);
            });

            return result;

在DB层中编写的代码:

public GeneralDAL.OperationStatus loadTimeline_bulk(List<Timeline> ListTimeline_bulk, string id_user)
        {
            GeneralDAL.OperationStatus operationStatus = GeneralDAL.OperationStatus.OperationSuccessful;
            try
            {
                SqlCommand sqlCommand = new SqlCommand(Returnsp_tbl_TimelineLstShow_bulk(id_user));
                sqlCommand.CommandType = CommandType.Text;
                using (SqlConnection connection = new SqlConnection(GeneralDAL.con))
                {
                    sqlCommand.Connection = connection;
                    try
                    {
                        connection.Open();
                        SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                        try
                        {
                            while (sqlDataReader.Read())
                                ListTimeline_bulk.Add(new Timeline()
                                {
                                    ID_Timeline_bulk = sqlDataReader.IsDBNull(sqlDataReader.GetOrdinal(Timeline.Fildes.ID_Timeline_bulk)) ? General.DefaultValues.Numricguid : sqlDataReader.GetGuid(sqlDataReader.GetOrdinal(Timeline.Fildes.ID_Timeline_bulk)),

和许多领域 但是当我调试expero时:

  

无法将类型为“ System.Int32”的对象转换为类型为“ System.String”。

0 个答案:

没有答案