I have problems reading a text column from SQL Server using the OleDbDataReader
The following code:

  ...

 OleDbCommand command = new OleDbCommand ("slp_GetMap", connection)
 command.CommandType = CommandType.StoredProcedure;
  ...

  byte[] buffer = new buffer[bufferLength];
  ...
  OleDbDataReader reader = command.ExecuteReader (CommandBehavior.SequentialAccess);

  long readed  = reader.GetBytes (0, 0, buffer, 0, bufferLength);

  string result = Encoding.Unicode.GetString (buffer,0, bufferLength);


works!, but the result contains garbage. Only a few chars are "normals".

the facts:
- The storedProcedure "slp_GetMap" is just a SELECT with the FOR XML clause to build a 
xml
representation of two tables.

- The chars are Unicode, returned in the byte array. Calling the GetChars throws un 
InvalidCast
exception.

- If I change the code to use the System.Data.SqlClient instead of System.Data.OleDb, 
the data
reads fine..


Maybe the table collation is not the correct, considering that the client is an OleDb?

I need to use the OleDb and can�t change to SqlClient, so I need to fix this problem 
wiht the
OleDb client...


Help, please..

!
Ernesto Giralt

=====
Ernesto Giralt H. /Software engineer
Sand!
e-Business Products
 Phone
 Web
(+34)93 464 28 92
http://www.esand.net/




___________________________________________________
Yahoo! Messenger - Nueva versi�n GRATIS
Super Webcam, voz, caritas animadas, y m�s...
http://messenger.yahoo.es

===================================
This list is hosted by DevelopMentor�  http://www.develop.com
Some .NET courses you may be interested in:

Guerrilla ASP.NET, 10 Nov 2003 in London and 26 Jan 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnet

Guerrilla .NET, 8 Dec 2003, in Los Angeles
http://www.develop.com/courses/gdotnet

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to