У меня есть этот код, где я делаю вставку, и возвращение дает мне эту ошибку.Вот мои функции:
{"Входная строка была в неправильном формате."}
public DataTable table(List<cliente> cli)
{
DataTable data = new DataTable();
data.Columns.Add("STATUS");
data.Columns.Add("FILIAL");
// here i add 54 columns
for (int i = 0; i < cli.Count; i++)
{
DataRow row = data.NewRow();
row["STATUS"] = status;
row["FILIAL"] = filial;
// here i add 54 rows
}
insert(data);
return data;
}
public void insert(DataTable dt)
{
try
{
using (var conn = new conexao_banco().conecta_banco())
{
#region lista de arrays para cada item
// here i add 54 arrays including date and double
int[] status = new int[dt.Rows.Count];
string[] filial = new string[dt.Rows.Count];
#endregion lista de arrays para cada item
for (int i = 0; i < dt.Rows.Count; i++)
{
status[i] = Convert.ToInt32(dt.Rows[i]?["STATUS"]);
filial[i] = Convert.ToString(dt.Rows[i]?["FILIAL"]);
// here i convert the arrays including date and double
}
#region oracleparameter
// I do the same here for all 54 columns
OracleParameter cliente_status = new OracleParameter();
cliente_status.OracleDbType = OracleDbType.Int32;
cliente_status.Value = status[0];
OracleParameter cliente_filial = new OracleParameter();
cliente_filial.OracleDbType = OracleDbType.Varchar2;
cliente_filial.Value = filial[0];
#endregion oracleparameter
conn.CommandText = "Insert into ped_ven_base" +
" (STATUS,FILIAL,TIPO_PEDIDO,KEY_PEDIDO_BASE,NUM_PEDIDO_INTERNO,NUM_PEDIDO_CLIENTE," +
"NUM_PEDIDO_VENDEDOR,COD_CLIENTE,FILIAL_CLIENTE,TEXTO_PADRAO_1,TEXTO_PADRAO_2,COD_TRANSACAO_1," +
"COD_TRANSACAO_2,COD_TRANSACAO_3,USUARIO_EMITENTE,USUARIO_CANCELADOR,MOTIVO_CANCELAMENTO," +
"DATA_EMISSAO,DATA_DIGITACAO,RAZAO_SOCIAL,ENDERECO,CEP,CGC_CIC,OBSERVACOES,COND_PAGTO,DATA_VALIDADE," +
"SITUACAO_PEDIDO,NOME_COMPRADOR,EMAIL,FONE,FAX,ENDERECO_COBRANCA,CEP_COBRANCA,USER_STRING,DATA_FECHADO," +
"DESTINO_USO,COD_FLAG_PEDIDO,DATA_PREVISTA_FATURAMENTO,STATUS_DE_LIBERACAO,USUARIO_LIBERACAO,DATA_LIBERACAO," +
"NOTAF_ORC,OBSERVACOES_REP,GERADO_AUTOMATICO,QTD_IMP_ETIQ,RAZAO_LOJISTA,VLR_TOT_IPI,KEY_NOTAF_BASE,PEDIDO_PAGO," +
"AGENCIA,FILIAL_AGENCIA,TIPO_COMISSAO,VALOR_COMISSAO,KEY_ORDEM_BASE)" +
" values (:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11,:12,:13,:14,:15,:16,:17,:18," +
":19,:20,:21,:22,:23,:24,:25,:26,:27,:28,:29,:30,:31,:32,:33,:34," +
":35,:36,:37,:38,:39,:40,:41,:42,:43,:44,:45,:46,:47,:48,:49,:50,:51,:52,:53,:54)";
#region adiciona paramentros no insert
// here I Add all the parameters from the OracleParameter I created.
conn.Parameters.Add(cliente_status);
conn.Parameters.Add(cliente_filial);
#endregion adiciona paramentros no insert
conn.ExecuteNonQuery();
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
Я удалил частькод для облегчения чтения.Если вы, ребята, хотите, я могу опубликовать код роли.В основном из того, что я удалил, я добавил комментарий к коду.
Вот полное исключение:
System.FormatException: A cadeia de caracteres de entrada não estava em um formato correto.
em System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
em System.Number.ParseInt64(String value, NumberStyles options, NumberFormatInfo numfmt)
em System.String.System.IConvertible.ToInt64(IFormatProvider provider)
em System.Convert.ToInt64(Object value)
em OracleInternal.ServiceObjects.OracleParameterImpl.SetInt32DataInBytes(Object paramValue, Byte[]& int32ByteArray)
em OracleInternal.ServiceObjects.OracleParameterImpl.SetInt32DataInBytes(Object paramValue)
em Oracle.ManagedDataAccess.Client.OracleParameter.PreBind_Int32()
em Oracle.ManagedDataAccess.Client.OracleParameter.PreBind(OracleConnectionImpl connImpl, ColumnDescribeInfo cachedParamMetadata, Boolean& bMetadataModified, Int32 arrayBindCount, ColumnDescribeInfo& paramMetaData, Object& paramValue, Boolean isEFSelectStatement, SqlStatementType stmtType)
em OracleInternal.ServiceObjects.OracleCommandImpl.InitializeParamInfo(ICollection paramColl, OracleConnectionImpl connectionImpl, ColumnDescribeInfo[] cachedParamMetadata, Boolean& bMetadataModified, Boolean isEFSelectStatement, MarshalBindParameterValueHelper& marshalBindValuesHelper)
em OracleInternal.ServiceObjects.OracleCommandImpl.ProcessParameters(OracleParameterCollection paramColl, OracleConnectionImpl connectionImpl, ColumnDescribeInfo[] cachedParamMetadata, Boolean& bBindMetadataModified, Boolean isEFSelectStatement, MarshalBindParameterValueHelper& marshalBindValuesHelper)
em OracleInternal.ServiceObjects.OracleCommandImpl.ExecuteNonQuery(String commandText, OracleParameterCollection paramColl, CommandType commandType, OracleConnectionImpl connectionImpl, Int32 longFetchSize, Int64 clientInitialLOBFS, OracleDependencyImpl orclDependencyImpl, Int64[]& scnFromExecution, OracleParameterCollection& bindByPositionParamColl, Boolean& bBindParamPresent, OracleException& exceptionForArrayBindDML, OracleConnection connection, OracleLogicalTransaction& oracleLogicalTransaction, Boolean isFromEF)
em Oracle.ManagedDataAccess.Client.OracleCommand.ExecuteNonQuery()
em promobimp.banco.insere_pedido.insere_base(DataTable dt) na C:\Users\Mario\Documents\projetos\marimport\banco\insere_pedido.cs:linha 625