473,568 Members | 2,923 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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)myReade r["buffer"];
it's trimed

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

It's possible to get
(string)myReade r["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 1872
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.co m

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

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

It's possible to get
(string)myReade r["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
2350
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: ************************************************* public void Export2CSV(){
3
5874
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 combo's text property (what the user will see). Is this possible with a SqlDataReader? Thanks
4
1861
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 a field by myRD, or myRD But how can we get the string index for the integer index. For example, sting sPassSubjects
5
2299
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 = CommandType.StoredProcedure Dim CustID As SqlParameter = cmd_sp_payments.Parameters.Add("@cust_id", SqlDbType.Text) CustID.Value = strCustID Dim...
1
3247
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 sqldatareader then sqldatareader.nextresult
9
10514
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: objMailMessage.To = dtrRecipient; I'm not sure why I am getting this error. Below is the complete code I am working with.
1
3359
by: Daniel | last post by:
is there any limit to how long of a string SqlDataReader.GetString() can return?
7
1814
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 found anyway to do that. It seems that I may need to create some functions instead of class and issue statement like this: Dim rdrCustomers As...
0
1536
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 databases in that server. Then after the user selects a database, I have another button that he/she click and I want to retrieve file groups from a...
0
7604
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7916
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8117
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6275
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5498
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2101
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.