Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel into DataTable using OleDbDataAdapter

Query fails to fetch Excel data formatted as currency. How can I get
currency data from Excel into a .NET DataSet. This query works fine for all
other Excel Data fields!

Thank you for your help.


//===========================
string xlsFile = fullFilePathStr;
DataSet importDS = new DataSet();
OleDbConnection objConn = null;
System.Data.DataTable dt = null;
string connString;
connString =
"Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + xlsFile + ";" +
"Extended Properties=Excel 8.0;";
objConn = new OleDbConnection(connString);

// Open connection with the database.
objConn.Open();

// Get the data table containg the schema guid.
dt = objConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables , null);
try
{
OleDbDataAdapter myCommand = new OleDbDataAdapter( " SELECT * FROM ["
+worksheetNameStr+ "$] ", objConn);
myCommand.AcceptChangesDuringFill=true;
importDS.EnforceConstraints=false;
myCommand.Fill(importDS);
}
catch(Exception ex)
{
string exStr = ex.ToString();
}

finally
{
if(objConn != null)
{
objConn.Close();
objConn.Dispose();
}
if(dt != null)
{
dt.Dispose();
}
}
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 593
Default Excel into DataTable using OleDbDataAdapter

Matthew_H wrote:
Query fails to fetch Excel data formatted as currency. How can I get


currency data from Excel


First, ensure your data actually is of type Currency. Formatting is a
factor but no guarantee e.g. Text in a column with a currency format is
still Text. Ensure you do not have a mixed types situation - see:

http://www.dicks-blog.com/archives/2...ed-data-types/

Jamie.

--

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chart's DataTable fujing1003 Charts and Charting in Excel 5 February 8th 07 11:20 AM
Needing to re-order a datatable display on an Excel chart Poody Charts and Charting in Excel 0 April 11th 06 01:40 PM
Can anyone align the numbers within the datatable of a chart? Chart Data Table Align Charts and Charting in Excel 1 September 2nd 05 06:41 PM
DataTable number format MB Excel Programming 2 January 21st 05 07:11 PM
Problems using VB.Net OleDbDataAdapter and Excel Terry H Excel Programming 2 March 1st 04 11:07 AM


All times are GMT +1. The time now is 06:58 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"