[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.odbcnet

ODBC .NET - Problem Reading Excel Spreadsheets

Carl Huff

9/19/2002 1:32:00 AM

I am using the ODBC .NET tool to read and write to Excel
spreadsheets. The problem is that the 'non varchar' column names
are not being returned by 'GetValue( anIndex).ToString()'.

Am I missing something? If GetValue() cannot be used to return
the non varchar column names, then what method do I use??

Suggestions and example code for reading Excel spreadsheets would
be welcomed. Thanks in advance.

*** Carl Huff




5 Answers

Ryszard Gawron

9/19/2002 11:51:00 AM

0

Hi Carl,
there are some article on this topic:
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q3...
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q3...
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q3...
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q3...
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q3...

I hope this helps

Ryszard Gawron

"Carl Huff" <chuff@toolworx.com> schrieb im Newsbeitrag
news:#6XI8p2XCHA.984@tkmsftngp12...
> I am using the ODBC .NET tool to read and write to Excel
> spreadsheets. The problem is that the 'non varchar' column names
> are not being returned by 'GetValue( anIndex).ToString()'.
>
> Am I missing something? If GetValue() cannot be used to return
> the non varchar column names, then what method do I use??
>
> Suggestions and example code for reading Excel spreadsheets would
> be welcomed. Thanks in advance.
>
> *** Carl Huff
>
>
>
>


Carl Huff

9/19/2002 10:41:00 PM

0

I appreciate the response but .....

the articles do not address my problem. I am using ODBC.NET and
think that I have found a bug.

The 'GetValue(index).ToString()' method using C# returns data for
every column type, but does not return
the column header for those columns that are not of type Varchar.

Is this a bug? Looks like it to me! Or is there another method
making up ODBC.NET that I am overlooking?

Thanks,

*** Carl Huff



"Ryszard Gawron" <rysiekg@hotmail.com> wrote in message
news:OmlNRT7XCHA.720@tkmsftngp12...
> Hi Carl,
> there are some article on this topic:
>
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q3...
>
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q3...
>
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q3...
>
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q3...
>
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q3...
>
> I hope this helps
>
> Ryszard Gawron
>
> "Carl Huff" <chuff@toolworx.com> schrieb im Newsbeitrag
> news:#6XI8p2XCHA.984@tkmsftngp12...
> > I am using the ODBC .NET tool to read and write to Excel
> > spreadsheets. The problem is that the 'non varchar' column
names
> > are not being returned by 'GetValue( anIndex).ToString()'.
> >
> > Am I missing something? If GetValue() cannot be used to
return
> > the non varchar column names, then what method do I use??
> >
> > Suggestions and example code for reading Excel spreadsheets
would
> > be welcomed. Thanks in advance.
> >
> > *** Carl Huff
> >
> >
> >
> >
>
>


(Douglas Laudenschlager [MS])

9/20/2002 11:21:00 PM

0


Could you show a short example of the code that's failing to retrieve
column names?

I would probably just check the ColumnName property of the DataColumn
objects in the DataTable's Columns collection.

-Doug



This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? For information about the Microsoft Strategic Technology
Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.co....

Carl Huff

9/23/2002 3:52:00 PM

0

> Could you show a short example of the code that's failing to
retrieve
> column names?
>

//... BEGIN CODE EXAMPLE ...

OdbcConnection lConn = new OdbcConnection( m_SwlStr );
lConn.Open();

m_Cmd = new OdbcCommand( "Select # FROM \"Sheet1$\"", lConn );
m_Rdr = m_Cmd.ExecuteReader();

// Here is where I read the columns ....
//
for( lIndex = 0; lIndex < m_Rdr.FieldCount; lIndex++ )
{
Trace.WriteLine( m_Rdr.GetValue( lIndex).ToString() );
}

// END CODE EXAMPLE ...

The 'GetValue' method should do an automatic conversion of the
underlying type and return a string. In fact what happens is
that the data returns as I expected, but the column names of
'non' string types return null.

The problem must be in the ODBC.NET piece as the equivalent C++
code calling the same ODBC driver returns the column names as
expected.

I hope this clarifies the problem.

Thanks,

Carl Huff



laled

9/28/2002 1:48:00 AM

0

The correct way to read the column names is through the
reader.GetName method. Try using
m_Rdr.GetName( lIndex)
to read the column names.

Thanx
Lale

This posting is provided "AS IS" with no warranties, and
confers no rights.


>-----Original Message-----
>> Could you show a short example of the code that's
failing to
>retrieve
>> column names?
>>
>
>//... BEGIN CODE EXAMPLE ...
>
>OdbcConnection lConn = new OdbcConnection( m_SwlStr );
>lConn.Open();
>
>m_Cmd = new OdbcCommand( "Select # FROM \"Sheet1$\"",
lConn );
>m_Rdr = m_Cmd.ExecuteReader();
>
>// Here is where I read the columns ....
>//
>for( lIndex = 0; lIndex < m_Rdr.FieldCount; lIndex++ )
>{
> Trace.WriteLine( m_Rdr.GetValue( lIndex).ToString
() );
>}
>
>// END CODE EXAMPLE ...
>
>The 'GetValue' method should do an automatic conversion
of the
>underlying type and return a string. In fact what
happens is
>that the data returns as I expected, but the column names
of
>'non' string types return null.
>
>The problem must be in the ODBC.NET piece as the
equivalent C++
>code calling the same ODBC driver returns the column
names as
>expected.
>
>I hope this clarifies the problem.
>
>Thanks,
>
>Carl Huff
>
>
>
>.
>