0
下面的代码:比较数据集的列类型
try
{
string strReadDataLine;
strReadDataLine = sr.ReadLine();
while (strReadDataLine != null)
{
string[] strReadDataLineSplited = strReadDataLine.Split(';');
DataRow thisRow = thisDataSet.Tables["Repartition"].NewRow();
DataTable item = thisDataSet.Tables["Repartition"];
for (int i = 0; i < strDataLines.Length; i++)
{
DataColumn thisColomn =
thisDataSet.Tables["Repartition"].Columns[i];
// Here i need to know if the colomn is a string
if (thisColomn.DataType.ToString() == "System.String")
{
thisRow[strDataLines[i]] = strReadDataLineSplited[i];
}
}
thisRow["ID_USAGER"] = 1;
thisDataSet.Tables["Repartition"].Rows.Add(thisRow);
strReadDataLine = sr.ReadLine();
}
//thisDataAdapter.Update(thisDataSet, "Repartition");
}
我需要的是知道,如果一列是分配一个数据字符串列的字符串。我得到的是一个argumentException,说“输入字符串格式不正确,无法在MY_FLOAT colomn中存储< 2.111>,期望类型是double。”
我真正需要的是将列类型与某种类型进行比较以获取该类型,然后将该列分配给正确的类型。
我希望这很清楚,因为我的英语不太好。
thisRow [strDataLines [I] 看起来像你不存储,你以为你是 – 2009-11-24 21:35:44
你可以发布你的表结构和一些样本数据的数据? – 2009-11-24 21:35:56