Hello all,
I'm performing the oracle bulk copy upload operation. There are 10 columns data which needs to be uploaded in oracle database table. The data is getting uploaded in the table for these 10 columns using a datatable. A datatable is being populated from the list.
However, there are 2 more columns in the datatable which needs to be uploaded in the same database table. These 2 columns are varchar2(50Byte) columns in database. When I include these 2 columns in the datatable and try to upload it to same database table, it shows the formatting error- "Input string was not in correct format.". The source and the destination columns mapping has been done correctly. The stack trace shows the following error "
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt64(String value, NumberStyles options, NumberFormatInfo numfmt)
at System.String.System.IConvertible.ToInt64(IFormatProvider provider)
at System.Convert.ToInt64(Object value)
at Oracle.DataAccess.Client.OracleBulkCopy.PerformBulkCopy()
at Oracle.DataAccess.Client.OracleBulkCopy.WriteDataSourceToServer()
at Oracle.DataAccess.Client.OracleBulkCopy.WriteToServer(DataTable table, DataRowState rowState)
at Oracle.DataAccess.Client.OracleBulkCopy.WriteToServer(DataTable table)
at InvestorTax.Repository.German.ManufacturedIncomeRepository.OracleBulkUpload(DataTable dtFinal, Dictionary`2 mapping, String tableName) in C:\Documents and Settings\admin\Desktop\upload\bulkupload\DemoBulk\Bulkupload.cs:line 572" "...

It seems that the string columns are being considered as numbers as per the stack trace. Can somebody give me the reason as to why it is happening. Thanks in advance.

Member Avatar for LastMitch

Input string was not in correct format

It means in there is a valve that doesn't contain a valid integer:

System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)

Can somebody give me the reason as to why it is happening. Thanks in advance.

It has something to do with the code you provide it

If you are using a DataGrid then it will probably return the type to you in StringToNumber().

You need to get the Value property instead.

You can also used Int32.TryParse Method:

http://msdn.microsoft.com/en-us/library/f02979c7.aspx

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.