带有 : 输入字符串的格式不正确
本文关键字:格式 不正确 字符串 输入 带有 | 更新日期: 2023-09-27 18:33:07
我在这里有一些错误,我没有问题如何解决它。它无法调用表的列表
我尝试调用调试,当它到达下面的语句时
List<Int32> ListintNo = DT_ExcludeNo.AsEnumerable().Select(x
=>Convert.ToInt32(x[0].ToString())).ToList();
请协助。
DataTable DT_ExcludeNo = new DataTable();
dataAdapter.Fill(DT_ExcludeNo);
InsertLogFile("AMB SP15: Validate Insert Data");
//InsertLogFile("AMB SP15: Execute Query: " + sSqlCommandRetrieveExcludeNO);
List<Int32> ListintNo = DT_ExcludeNo.AsEnumerable().Select(x => Convert.ToInt32(x[0].ToString())).ToList();
for (Int32 i = 1; i <= TotalCount; i++)
{
foreach (Int32 intNo in ListintNo)
{
if (i == intNo)
{
string sSqlCommandRetrieveData = "SELECT Name, [I.C], [D.O.B], NO, [EFF DATE], Sum_Insured from AMB_Temp WHERE NO = " + i;
SqlCommand obj_SQLCommand = new SqlCommand(sSqlCommandRetrieveData, myconn);
dataAdapter = new SqlDataAdapter(obj_SQLCommand);
DataSet DS_RetrieveData = new DataSet();
dataAdapter.Fill(DS_RetrieveData);
//InsertLogFile("AMB SP15: Execute Query: " + sSqlCommandRetrieveData);
DataValidation(DS_RetrieveData);
}
以下是更新的代码:
//start new code
string fieldString = x[0].ToString();
if (string.IsNullOrEmpty(fieldString))
{
fieldString = "0";
}
//InsertLogFile("AMB SP15: Execute Query: " + sSqlCommandRetrieveExcludeNO);
List<Int32> ListintNo = DT_ExcludeNo.AsEnumerable().Select(x => Convert.ToInt32(fieldString )).ToList();
//end new code
DataTable DT_ExcludeNo = new DataTable();
dataAdapter.Fill(DT_ExcludeNo);
InsertLogFile("AMB SP15: Validate Insert Data");
//InsertLogFile("AMB SP15: Execute Query: " + sSqlCommandRetrieveExcludeNO);
string fieldString = x[0].ToString();
if (string.IsNullOrEmpty(fieldString))
{ fieldString = "0"; }
List<Int32> ListintNo = DT_ExcludeNo.AsEnumerable().Select(x => Convert.ToInt32(fieldString)).ToList();
for (Int32 i = 1; i <= TotalCount; i++)
{
foreach (Int32 intNo in ListintNo)
{
if (i == intNo)
{
string sSqlCommandRetrieveData = "SELECT Name, [I.C], [D.O.B], NO, [EFF DATE], Sum_Insured from AMB_Temp WHERE NO = " + i;
SqlCommand obj_SQLCommand = new SqlCommand(sSqlCommandRetrieveData, myconn);
dataAdapter = new SqlDataAdapter(obj_SQLCommand);
DataSet DS_RetrieveData = new DataSet();
dataAdapter.Fill(DS_RetrieveData);
//InsertLogFile("AMB SP15: Execute Query: " + sSqlCommandRetrieveData);
DataValidation(DS_RetrieveData);
}
请检查您的数据库列字段数据类型是否为 NO
如果它是VarChar or Char
您必须更改您的 where 语句。
string sSqlCommandRetrieveData = "SELECT Name, [I.C], [D.O.B], NO, [EFF DATE], Sum_Insured from AMB_Temp WHERE NO = " + Convert. ToString(i);