473,386 Members | 1,819 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,386 software developers and data experts.

extra characters on string

Hi,

I am retrieving data from a binary field from a sql table and I am having a
problem with extra characters being tacked onto the end. The thePass
variable has some unknown spaces after it but I can't seem to trim them. Any
help would be appreciated.

Thanks

Here is the sql statement I am using

SELECT CAST(password AS VARCHAR(50)) AS thePass FROM " + Session["dbOwner"]
+ "tblpassword WHERE USERNAME = '" + userName + "'"

Sep 12 '07 #1
2 1746
"bbdobuddy" <bb*******@discussions.microsoft.comwrote in message
news:65**********************************@microsof t.com...
I am retrieving data from a binary field from a sql table and I am having
a
problem with extra characters being tacked onto the end. The thePass
variable has some unknown spaces after it but I can't seem to trim them.
Any
help would be appreciated.

Here is the sql statement I am using

SELECT CAST(password AS VARCHAR(50)) AS thePass FROM " +
Session["dbOwner"]
+ "tblpassword WHERE USERNAME = '" + userName + "'"
What is the original type of the column "password"? Since you are casting
it to varchar, I assume that it was not originally a varchar. Maybe the type
of conversion that is taking place can give us a hint as to why additional
characters are appearing.

On a different note, be aware that this statement suffers a risk of
being subject to a sql injection. If the user, when entering the userName,
typed (for example) something like "';drop table tblpassword--", you would
be in trouble.

Sep 12 '07 #2
Hi,

"bbdobuddy" <bb*******@discussions.microsoft.comwrote in message
news:65**********************************@microsof t.com...
Hi,

I am retrieving data from a binary field from a sql table and I am having
a
problem with extra characters being tacked onto the end. The thePass
variable has some unknown spaces after it but I can't seem to trim them.
Any
help would be appreciated.
Why are you casting it as varchar?
What does the original column hold? , In what format?
>
Thanks

Here is the sql statement I am using

SELECT CAST(password AS VARCHAR(50)) AS thePass FROM " +
Session["dbOwner"]
+ "tblpassword WHERE USERNAME = '" + userName + "'"

Sep 12 '07 #3

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

Similar topics

10
by: Tank | last post by:
First off let me say that I am by no means a skilled programmer so i probably have made a dozen mistakes in my attempt at coding my problem. I will tell you the problem so that you have an idea of...
11
by: serge calderara | last post by:
Dear all, I have a csv file which as following output : "REC00001.CSV","Pipe","25 x 2.5 mm","LP602","LP602","02/11/2004 15:15:04" I need to remove from that string doucble quote char. In...
5
by: Brian Reed | last post by:
I have a class that I want to serialize to an XML string. I want the XML to serialize to utf-8 encoding. When I serialize to an XML file, the data looks great. When I try to serialize to a String...
11
by: santosh | last post by:
Hi, A book that I'm currently using notes that the fgets() function does not return until Return is pressed or an EOF or other error is encountered. It then at most (in the absence of...
2
by: ricky | last post by:
Can anybody help with the function to get rid of extra characters in the file. I want to remove the string from the file.So i read from input file and pass the string say "john" if found dnt write...
34
by: Registered User | last post by:
Hi experts, I'm trying to write a program that replaces two or more consecutive blanks in a string by a single blank. Here's what I did: #include <stdio.h> #include <string.h> #define MAX 80
2
by: lonni4000 | last post by:
My parser parses special characters okay, but adds extra line breaks. It makes no sense to me at all! If anyone knows what I am doing wrong, please help. text file: <?xml version="1.0"...
7
by: Steven Blair | last post by:
string USMesg; USMesg = "¬Credits¬Remaining¬"; byte bArray = Encoding.UTF8.GetBytes(USMesg); After I execute the code, the first two bytes are: = 0xC2 = 0xAC //This is the character I...
3
by: webqueen79 | last post by:
When I open up my asp code in an editor, I see TONS of extra whitespace between code lines which is making the editor bomb out because it takes so long to load all the lines. When I open up the asp...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...

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.