473,796 Members | 2,512 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

convert binary(20) to string

SM
Hi,

I have a column with SQL Server type binary(20) (contain a sql handle, ex :
0x01000800B73B5 73B98C6B1030000 000000000000)

I want to convert this column to string value with this code :

string sql_hndl = MyDataRow["ColWithBinaryT ype"].tostring;

I'm expecting '0x01000800B73B 573B98C6B103000 0000000000000' string value, but
I've got 'array[]' value

Is there any simple way to convert sql server binary type to string

Thank you for your help
Feb 20 '07 #1
3 8184
The first question I would ask is, "what on earth do you expect to be able to
do with the string representation of a SQLHandle?".

You will probably need to do something like:

string s = System.Text.Enc oding.UTF8.GetS Tring( (byte[])
MyDataRow["ColWithBinaryT ype"] )

Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"SM" wrote:
Hi,

I have a column with SQL Server type binary(20) (contain a sql handle, ex :
0x01000800B73B5 73B98C6B1030000 000000000000)

I want to convert this column to string value with this code :

string sql_hndl = MyDataRow["ColWithBinaryT ype"].tostring;

I'm expecting '0x01000800B73B 573B98C6B103000 0000000000000' string value, but
I've got 'array[]' value

Is there any simple way to convert sql server binary type to string

Thank you for your help
Feb 20 '07 #2
SM
Thank you
The conversion did not work, I need SQL Handle to capture query that block
other process (::fn_get_sql() )
Never mind I've process all things in server side

"Peter Bromberg [C# MVP]" <pb*******@yaho o.yabbadabbadoo .comwrote in
message news:2A******** *************** ***********@mic rosoft.com...
The first question I would ask is, "what on earth do you expect to be able
to
do with the string representation of a SQLHandle?".

You will probably need to do something like:

string s = System.Text.Enc oding.UTF8.GetS Tring( (byte[])
MyDataRow["ColWithBinaryT ype"] )

Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"SM" wrote:
>Hi,

I have a column with SQL Server type binary(20) (contain a sql handle,
ex :
0x01000800B73B 573B98C6B103000 0000000000000)

I want to convert this column to string value with this code :

string sql_hndl = MyDataRow["ColWithBinaryT ype"].tostring;

I'm expecting '0x01000800B73B 573B98C6B103000 0000000000000' string value,
but
I've got 'array[]' value

Is there any simple way to convert sql server binary type to string

Thank you for your help

Feb 21 '07 #3


"SM" <sa*******@yaho o.comwrote in message
news:##******** ******@TK2MSFTN GP02.phx.gbl...
Hi,

I have a column with SQL Server type binary(20) (contain a sql handle, ex
:
0x01000800B73B5 73B98C6B1030000 000000000000)

I want to convert this column to string value with this code :

string sql_hndl = MyDataRow["ColWithBinaryT ype"].tostring;

I'm expecting '0x01000800B73B 573B98C6B103000 0000000000000' string value,
but I've got 'array[]' value

Is there any simple way to convert sql server binary type to string

Thank you for your help
Quick sample:

byte[] bytes = dataRow.BinaryF ieldHere;
StringBuilder sb = new StringBuilder() ;
foreach (byte b in bytes) {
sb = sb.Append(b.ToS tring("X").PadL eft(2, '0'));
}

if (sb.Length 0) {
sb = sb.Insert(0, "0x");
}

string binaryString = sb.ToString();

HTH (untested),
Mythran
Feb 21 '07 #4

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

Similar topics

1
2320
by: Johannes | last post by:
Hi, I tried to pack eight integer values and one string into one binary string, which I would like to store in a mysql db. I encountered two problems doing this: 1) $this->packed = pack('N8A*', $this->value1, $this->value2, $this->value3, $this->value4, $this->value5, $this->value6, $this->value7, $this->value8, $this->stringvalue);
5
2926
by: sathyashrayan | last post by:
Group, I have some doubts in the following program. ------------------program--------------------- /* ** Make an ascii binary string into an integer. */ #include <string.h> unsigned int bstr_i(char *cptr)
10
2386
by: jt | last post by:
I'm needing to take a binary string start at a certain position and return a pointer from that postion to the end of the binary stirng. something like this: char bstr; char *pos; pos=mid(bstr,35); / *return a pointer of the rest of the binary string starting at element 35 */
4
4293
by: CSharpener | last post by:
This should be *so* easy! How do I convert a Byte or int to a binary string representation in C# In JavaScript, it goes like this for an int: javascript:(123).toString(2 or javascript:(0xFE).toString(2 No problem. So, how do I do the same in C#? What simple thing am I missing
6
2593
by: young_leaf | last post by:
Using STL how do I convert a variable to a binary string but with special case which for example BYTE x, i need only the first 3 bits of this byte, is that possible? to be more specific, from that byte i want to generate (so valid values for x will be 0-5) 000 001
7
19235
by: elliotng.ee | last post by:
I have a text file that contains a header 32-bit binary. For example, the text file could be: %%This is the input text %%test.txt Date: Tue Dec 26 14:03:35 2006 00000000000000001111111111111111 11111111111111111111111111111111 00000000000000000000000000000000 11111111111111110000000000000000
5
28478
by: gezerpunta | last post by:
Hi strlen does not return the correct value .I compared the filesize() and strlen byte size but they are not equal. I must find binary string length and it must be equal to filesize() thks.
35
4933
by: Abandoned | last post by:
I want to convert a string to command.. For example i have a string: a="" I want to do this list.. How can i do ?
12
13566
by: Peter | last post by:
Trying to convert string to byte array. the following code returns byte array of {107, 62, 194, 139, 64} how can I convert this string to a byte array of {107, 62, 139, 65} System.Text.UTF8Encoding str = new System.Text.UTF8Encoding(); string s = new string((char)107, 1); s += new string((char)62, 1);
0
9525
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10169
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10003
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9050
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6785
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5440
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5569
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.