473,399 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

How can i get the whole string with SqlDataReader?

I have a varchar 255 field in the Sql.
When i get the data with (string)myReader["buffer"];
it's trimed

ie(
SQL : "qwerty " (Lenght 255)
c# : (string)myReader["buffer"].Lenght; (=5)

It's possible to get
(string)myReader["buffer"].Lenght; (=255)

Of course a trick is to use PADL with SPACE

But anyway to do it wihout PADL?

Thanks,
Nov 16 '05 #1
1 1859
smeagol,

If you need the padding, then why not define the field as a char field?
This way, you always get the padding.

You could always call the sp_columns stored procedure (once), and get
the length of the field from that (you can store it as well, since your
schema should not change during the course of execution) and pad
appropriately.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"smeagol" <pedorro77.hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I have a varchar 255 field in the Sql.
When i get the data with (string)myReader["buffer"];
it's trimed

ie(
SQL : "qwerty " (Lenght 255)
c# : (string)myReader["buffer"].Lenght; (=5)

It's possible to get
(string)myReader["buffer"].Lenght; (=255)

Of course a trick is to use PADL with SPACE

But anyway to do it wihout PADL?

Thanks,

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Franck Diastein | last post by:
Hi, when I call ExportData I have this error: Invalid attempt to Read when reader is closed. Telling me that there's a problem with this line: while(_dataR.Read()){ Code:...
3
by: Neil Guyette | last post by:
Hello, Everyone, I'm trying to find information on how to populate a combo box using a SqlDataReader. I want to be able to set the value of the combo's value property different then the...
4
by: ad | last post by:
When we user SqlDataReader, we can use integer or string as index. For example, if the query string is : Select Math, Nature, Social form Scores" and the myRD is the SqlDataReader, We can refer...
5
by: Catalin Porancea | last post by:
Whenever I try this: ____________________________________________________________________ Dim cmd_sp_payments As SqlCommand = New SqlCommand("sp_payments", con) cmd_sp_payments.CommandType =...
1
by: Arvind P Rangan | last post by:
Hi All, How do you get all the values of a sqldatareader if it contains multiple resultset. Using sqldatareader.nextresult and sqldatareader.read e.g. While sqldatareader.read ' If not...
9
by: Andy Sutorius | last post by:
Hi, I am receiving the error when compiling the project, "cannot implicitly convert type object to string". The error points to this line of code and underlines the dtrRecipient:...
1
by: Daniel | last post by:
is there any limit to how long of a string SqlDataReader.GetString() can return?
7
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
I'm trying to create a generic class which will take a command string and I can issue statement like this: Dim rdrCustomers As New Generic_Reader("select * from customers") However, I have not...
0
by: TG | last post by:
Hi! Once again I have hit a brick wall here. I have a combobox in which the user types the server name and then clicks on button 'CONNECT' to populate the next combobox which contains all the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.