Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / September 2007

Tip: Looking for answers? Try searching our database.

extra characters on string

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bbdobuddy - 12 Sep 2007 17:40 GMT
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 + "'"
Alberto Poblacion - 12 Sep 2007 17:51 GMT
> I am retrieving data from a binary field from a sql table and I am having
> a
[quoted text clipped - 8 lines]
> 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.
Ignacio Machin ( .NET/ C# MVP ) - 12 Sep 2007 18:16 GMT
Hi,

> Hi,
>
[quoted text clipped - 4 lines]
> Any
> help would be appreciated.

Why are you casting it as varchar?
What does the original column hold? , In what format?

> Thanks
>
[quoted text clipped - 3 lines]
> Session["dbOwner"]
> + "tblpassword WHERE USERNAME = '" + userName + "'"

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.