DataColumn col = ds.Tables["emp"].Columns[i];
string sql = "SELECT NUMERIC_PRECISION,NUMERIC_SCALE,DATETIME_PRECISION" +
"FROM INFORMATION_SCHEMA.COLUMNS" +
"WHERE(TABLE_NAME = 'employes') AND (COLUMN_NAME= "+col.ColumnName + ")";
SqlDataAdapter adapter = new SqlDataAdapter(sql, mycon);
dt = getDataSet("info", sql);
ds1.Tables.Add(dt);
if (ds1.Tables[0].Rows[0][0]!=null)
// date
t[i] = (int)ds1.Tables[0].Rows[0][0] + (int)ds1.Tables[0].Rows[i][2];
else
{
if ((int)ds1.Tables["info"].Rows[0][1] == 0) // entier
t[i] = (int)ds1.Tables[0].Rows[0][0];
else // pour les float
t[i] = (int)ds1.Tables[0].Rows[0][0] + (int)ds1.Tables[0].Rows[0][1] + 1;
}
}
else
t[i] = col.MaxLength; // les varchars
Partager