Re: Accessing Excel thru Jet gives data in scientific notation by 1SALz
1SALz
Fri Nov 21 13:31:05 CST 2003
A few more tries ... but without success.
select F1, F2, F3, iif(isnumeric(f3),val(F3),f3) from myNamedCells
Although now the code works without error, but the values are losing
precision.
Original Value in Excel: 4509015281
Default Loaded Value: 4.50902e+009
Converted Value by val : 4509020000
The problem looks like the value is being read as text (in scientific
notation) from the source.
Any ideas ?
"1SALz" <salman_z_g@hotmail.com> wrote in message
news:u3$q$SFsDHA.2252@TK2MSFTNGP09.phx.gbl...
> Thanks.
> I tried it (select str(F1) from myNamedCells) but that gave the following
> error:
>
> System.InvalidOperationException: The provider could not determine the
> String value. For example, the row was just created, the default for the
> String column was not available, and the consumer had not yet set a new
> String value.
> at System.Data.OleDb.DBBindings.get_Value()
> at System.Data.OleDb.OleDbDataReader.GetValues(Object[] values)
> at System.Data.Common.SchemaMapping.LoadDataRow(Boolean
clearDataValues,
> Boolean acceptChanges)
> at System.Data.Common.DbDataAdapter.FillLoadDataRow(SchemaMapping
> mapping)
> at System.Data.Common.DbDataAdapter.FillFromReader(Object data, String
> srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords,
> DataColumn parentChapterColumn, Object parentChapterValue)
> at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String
> srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
> at System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32
> startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
> CommandBehavior behavior)
> at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
> startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
> CommandBehavior behavior)
> at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
> at project1.WebForm1.myfunction(String fileName) in
> c:\inetpub\wwwroot\webform1.aspx.cs:line 70
>
>
> "Kevin Yu [MSFT]" <v-kevy@online.microsoft.com> wrote in message
> news:FhPpc3AsDHA.3024@cpmsftngxa07.phx.gbl...
> > Hi 1SALz,
> >
> > It is by design that Excel will convert the numeric data to scientific
> > notation automatically. The workaround is select this column as a string
> > field. You can try to use the following statement to convert it to a
> string
> > data.
> >
> > SELECT str(id) FROM table11
> >
> > Kevin Yu
> > =======
> > "This posting is provided "AS IS" with no warranties, and confers no
> > rights."
> >
>
>