我写入的数据库有一个双数据类型而不是整数(DRAMT和CRAMT列),即使我已经将表列初始化为整数。我怀疑是因为我的操作如下。真的不知道如何处理这个问题,以便所说的列显示为整数而没有浮点。
int dramt = 0;
int cramt = 0;
double ddramt = 0;
double ccramt = 0;
if (type == "50")
ddramt = 100 *dt.Rows[n].Field<double>(2);
else if(type == "51")
ccramt = 100 *dt.Rows[n].Field<double>(2);
cmd.Parameters.Add("@DRAMT", OleDbType.Integer).Value = dramt;
cmd.Parameters.Add("@CRAMT", OleDbType.Integer).Value = cramt;
用于创建表格的代码如下所示:
command.CommandText = "CREATE TABLE " + FileName + " ([JNL] VarChar(4), " +
"[LINE] VarChar(5), "+
"[TYPE] VarChar(6), "+
"[DRACC] VarChar(9), "+
"[CRACC] VarChar(9), "+
"[EXPDRACC] VarChar(11), "+
"[EXPCRACC] VarChar(11), "+
"[DRSTITLE] VarChar(9), "+
"[CRSTITLE] VarChar(9), "+
"[DOCDATE] DateTime, "+
"[REF] VarChar(8), "+
"[DRAMT] Integer, "+
"[CRAMT] Integer, "+
"[LARGE] VarChar(7), "+
"[DESC] VarChar(6), "+
"[TRACE] VarChar(6), "+
"[TRNDR] VarChar(7), "+
"[TRNCR] VarChar(7), "+
"[PARTS1] VarChar(8), "+
"[PARTS2] VarChar(8), "+
"[PARTS3] VarChar(8), "+
"[PARTS4] VarChar(8), "+
"[PARTS5] VarChar(8))";