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

varbinary to nvarchar to string

Hello All
I have a field which is of type varbinary(256). Now in my sql
statement I cast it to nvarchar but when do the DataReader.GetString()
method, I get the string with \0 at the end.

This is what I do in the SQL statement
cast(S.ObjectMoniker as nvarchar(100)) as Filepath

When I try this
string filename = oDbReader.GetString(iFilePathOrdinal)

I get the filenam as \\test\filename1\0

any ideas what I need to do here..??

thanks
Sunit
sj****@ingr.com
Nov 16 '05 #1
1 9623
Sunit Joshi <sj****@ingr.com> wrote:
I have a field which is of type varbinary(256). Now in my sql
statement I cast it to nvarchar but when do the DataReader.GetString()
method, I get the string with \0 at the end.

This is what I do in the SQL statement
cast(S.ObjectMoniker as nvarchar(100)) as Filepath

When I try this
string filename = oDbReader.GetString(iFilePathOrdinal)

I get the filenam as \\test\filename1\0

any ideas what I need to do here..??


I'm assuming you're not looking for "don't use a binary field for text
data" :)

You can trim the end with String.TrimEnd('\0').

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2

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

Similar topics

0
by: Eugene | last post by:
Hi, I have been battling with this for days now. If you execute the SQL below you will get the following result: 0x3078303030303030, which is incorrect. It looks like the conversion is more...
1
by: Maciej | last post by:
Hello I have some problems with converting varbinary to float in T-SQL stored procedure. In my C# application i have table of structures with double type fields. Size of this table is variant. I...
8
by: Vinod | last post by:
Hi, I have a stored procedure which expects a varbinary datatype. How can i pass a varbinary datatype from asp.net directly to the stored procedure. I tried using the Convert function in Sql...
2
by: Bill Nguyen | last post by:
I need sample code to insert binary file (mappoint map file) into a varbinary column using VB.NET. Please help! Thanks Bill
4
by: D. | last post by:
Hi, I'm starting a new application in java using JTDS jdbc driver (http://jtds.sourceforge.net) and SQLServer 2005 Express. I have to design the database from scratch and my doubt is if I have to...
1
by: Karch | last post by:
I am doing some experimenting with serialization (for use with Service Broker) and I am having a problem converting from a .NET DateTime (in the client application) to a SqlDbType.VarBinary (as...
0
by: Analizer1 | last post by:
can you conver a Varbinary to varchar declare @sid varbinary(85) select @sid = suser_sid("mydomain\mynam") // how to convert the sid to a string or do i need to //convert it in code to byte...
4
by: Martin Horst | last post by:
Hi, I've got an application which is written in .Net 1.1. When I try to write a varbinary(max) field using the SqlCommand and SqlParameter classes I got an exception like this: "The...
1
by: quintonmartin | last post by:
Here's my problem. I have a client application that uses a web service for data access. I can read/update many records in many tables, however, I am not getting what I expect for a varbinary(max)...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.