首页 > 代码库 > DataTable 数据导入MS ACCESS 数据库中 数字类型字段为空的解决办法

DataTable 数据导入MS ACCESS 数据库中 数字类型字段为空的解决办法

 1 string strSql = 2                         "insert into GongCheng (GCSY,GCBH,GCBHOLD,GCMC,GCKCJD,GCJSDW,GCSJDW,GCKCDW,GCSGDW,GCDD,GCX,GCY,GCBG,GCQSLC,GCJSLC,GCZXDH,GCZXLC,GCZXLX,GCZXSM,GCYX,GCZBZ,GCBLC,GCBZ,PZFA,BZ,GCSJ,DTABLE,ZGSW,DZJL,DZLD,JCMS,JQBS,FGCH,TLX,CDLB,YHZS,GCMM,TZBH,KGRQ,WGRQ,VERSION,GCZBX,GCGCX) VALUES (@GCSY,@GCBH,@GCBHOLD,@GCMC,@GCKCJD,@GCJSDW,@GCSJDW,@GCKCDW,@GCSGDW,@GCDD,@GCX,@GCY,@GCBG,@GCQSLC,@GCJSLC,@GCZXDH,@GCZXLC,@GCZXLX,@GCZXSM,@GCYX,@GCZBZ,@GCBLC,@GCBZ,@PZFA,@BZ,@GCSJ,@DTABLE,@ZGSW,@DZJL,@DZLD,@JCMS,@JQBS,@FGCH,@TLX,@CDLB,@YHZS,@GCMM,@TZBH,@KGRQ,@WGRQ,@VERSION,@GCZBX,@GCGCX)"; 3                     OleDbCommand cmd = new OleDbCommand(strSql, con); 4                     cmd.Parameters.AddWithValue("@GCSY", dataRow["GCSY"]); 5                     cmd.Parameters.AddWithValue("@GCBH", dataRow["GCBH"]); 6                     cmd.Parameters.AddWithValue("@GCBHOLD", dataRow["GCBHOLD"]); 7                     cmd.Parameters.AddWithValue("@GCMC", dataRow["GCMC"]); 8                     cmd.Parameters.AddWithValue("@GCKCJD", dataRow["GCKCJD"]); 9                     cmd.Parameters.AddWithValue("@GCJSDW", dataRow["GCJSDW"]);10                     cmd.Parameters.AddWithValue("@GCSJDW", dataRow["GCSJDW"]);11                     cmd.Parameters.AddWithValue("@GCKCDW", dataRow["GCKCDW"]);12                     cmd.Parameters.AddWithValue("@GCSGDW", dataRow["GCSGDW"]);13                     cmd.Parameters.AddWithValue("@GCDD", dataRow["GCDD"]);14                     cmd.Parameters.AddWithValue("@GCX", (object)dataRow["GCX"] ?? DBNull.Value);15                     cmd.Parameters.AddWithValue("@GCY", (object)dataRow["GCY"] ?? DBNull.Value);16                     cmd.Parameters.AddWithValue("@GCBG", (object)dataRow["GCBG"] ?? DBNull.Value);17                     cmd.Parameters.AddWithValue("@GCQSLC", (object)dataRow["GCQSLC"] ?? DBNull.Value);18                     cmd.Parameters.AddWithValue("@GCJSLC", (object)dataRow["GCJSLC"] ?? DBNull.Value);19                     cmd.Parameters.AddWithValue("@GCZXDH", (object)dataRow["GCZXDH"] ?? DBNull.Value);20                     cmd.Parameters.AddWithValue("@GCZXLC", (object)dataRow["GCZXLC"] ?? DBNull.Value);21                     cmd.Parameters.AddWithValue("@GCZXLX", dataRow["GCZXLX"]);22                     cmd.Parameters.AddWithValue("@GCZXSM", dataRow["GCZXSM"]);23                     cmd.Parameters.AddWithValue("@GCYX", (object)dataRow["GCYX"] ?? DBNull.Value);24                     cmd.Parameters.AddWithValue("@GCZBZ", (object)dataRow["GCZBZ"] ?? DBNull.Value);25                     cmd.Parameters.AddWithValue("@GCBLC", (object)dataRow["GCBLC"] ?? DBNull.Value);26                     cmd.Parameters.AddWithValue("@GCBZ", (object)dataRow["GCBZ"] ?? DBNull.Value);27                     cmd.Parameters.AddWithValue("@PZFA", (object)dataRow["PZFA"] ?? DBNull.Value);28                     cmd.Parameters.AddWithValue("@BZ", dataRow["BZ"]);29                     cmd.Parameters.AddWithValue("@GCSJ", (object)dataRow["GCSJ"] ?? DBNull.Value);30                     cmd.Parameters.AddWithValue("@DTABLE", dataRow["DTABLE"]);31                     cmd.Parameters.AddWithValue("@ZGSW", (object)dataRow["ZGSW"] ?? DBNull.Value);32                     cmd.Parameters.AddWithValue("@DZJL", (object)dataRow["DZJL"] ?? DBNull.Value);33                     cmd.Parameters.AddWithValue("@DZLD", (object)dataRow["DZLD"] ?? DBNull.Value);34                     cmd.Parameters.AddWithValue("@JCMS", (object)dataRow["JCMS"] ?? DBNull.Value);35                     cmd.Parameters.AddWithValue("@JQBS", (object)dataRow["JQBS"] ?? DBNull.Value);36                     cmd.Parameters.AddWithValue("@FGCH", (object)dataRow["FGCH"] ?? DBNull.Value);37                     cmd.Parameters.AddWithValue("@TLX", (object)dataRow["TLX"] ?? DBNull.Value);38                     cmd.Parameters.AddWithValue("@CDLB", (object)dataRow["CDLB"] ?? DBNull.Value);39                     cmd.Parameters.AddWithValue("@YHZS", (object)dataRow["YHZS"] ?? DBNull.Value);40                     cmd.Parameters.AddWithValue("@GCMM", dataRow["GCMM"]);41                     cmd.Parameters.AddWithValue("@TZBH", dataRow["TZBH"]);42                     cmd.Parameters.AddWithValue("@KGRQ", dataRow["KGRQ"]);43                     cmd.Parameters.AddWithValue("@WGRQ", dataRow["WGRQ"]);44                     cmd.Parameters.AddWithValue("@VERSION", dataRow["VERSION"]);45                     cmd.Parameters.AddWithValue("@GCZBX", dataRow["GCZBX"]);46                     cmd.Parameters.AddWithValue("@GCGCX", dataRow["GCGCX"]);47                     cmd.ExecuteNonQuery();

 

DataTable 数据导入MS ACCESS 数据库中 数字类型字段为空的解决办法