问题:当从sql数据库中select数据集后,如何判断某字段的类型?

解决: 

                               foreach (System.Data.DataColumn dc in dsFirst.Tables[0].Columns)
                                {
                                    if (s == dc.ColumnName && dc.DataType == typeof(DateTime))
                                    {
                                        strTemp = strTemp + " cstr(" + s + ")+";
                                        break;
                                    }
                                    else if (s == dc.ColumnName)
                                    {
                                        strTemp = strTemp + "[" + s + "]+";
                                        break;
                                    }

                                }

posted on 2011-06-09 15:49  smiling face  阅读(811)  评论(0编辑  收藏  举报