473,498 Members | 1,833 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reading Binary(16) field problem

2 New Member
I am working with a sql server database. Due to a database udgrade, sever fields which were integer are now binary(16). These fields are used for joins later in the VB project. The problem I am haveing is that I have no idea how to read in the binary field! Here is the original code(using Visual Studio 08):

strRptPars(iCount).lID = adoOleDbDataReader.GetInt32(i)

Originally strRptPars(iCount).lID was defined as LONG. I tried changing it to STRING, and using adoOleDbDataReader.GetString(i). However, instead of getting the string rep of the binary field, I am getting the literal 'S' for read. Not sure what I am doing wrong - if anyone can help or direct me to a more appropriate forum for this you have my thanks!
Apr 7 '09 #1
2 1835
iam_clint
1,208 Recognized Expert Top Contributor
binary 16 representation of an int would look like this

0x000000001
0x000000002

the easiest solution is to cast this in your sql if you want an integer

select cast(column as int) as whatever from table


this would give you the integer you are looking for.. however why do you want an integer column to be binary 16 in the first place why not convert these back to integers?
Apr 14 '09 #2
RoddyPiper
2 New Member
Hello - the original field in the database was integer, but was converted to binary(16). At any rate, I am able to read it now with the .GetBytes method, but I never though of doing a cast - something to remember in the future. I'm updating someone else's code and it is a real nightmare. If I had to do it over again I would have told the client that I am rewriting the damn thing from scratch. Thanks for your suggestion.
Apr 18 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1214
by: dw | last post by:
I want to create a databound dropdown list with "Yes" = 1 and "No" = 0. I set the collection up with the two values and databind it to a binary field (sql server) and the only entry in dropdown...
0
2462
by: Channing Jones | last post by:
Hello everyone, I am trying to store data in a binary field of an SQL-Server table using ADODB. So far, I have managed to store a record but not any data in the binary field. I only get...
2
2104
by: deko | last post by:
I'm wondering if anyone has come across something like this before and could offer some suggestions. I need to extract all the Single values packed in a Long Binary field (4k chunks) and then...
2
2459
by: Sabin Finateanu | last post by:
Hi I'm having problem reading a file from my program and I think it's from a procedure I'm using but I don't see where I'm going wrong. Here is the code: public bool AllowUsage() { ...
8
7226
by: junk5 | last post by:
Hi I need to read raw 16 bit data from a file, where the first byte is the most significant byte of the first data value and the second byte is the least significant byte of the first data value...
0
1416
by: S Wheeler | last post by:
Hi All - I am creating a upgrade utility that transfers an bin / exe image over an xml stream. But I can not seem to get the deserialization of the binary field to work correctly. What I have is...
1
1229
by: shaktishakya | last post by:
why does mssql encrypt or convert the values (entered through sql query into a binary field) into hexadecimal values. When I query and print them from php, it displays some unicode characters. How...
1
3751
by: Asking | last post by:
Hi all, how to save/read content of a RichTextBox to/from binary field in Ms.SQL Server ? I want to do save and read operation... I couldn't it Thank you
1
1550
by: John Wright | last post by:
I have a device hooked up to my COM port that I read data from the serial port into my program. If the device is in its double mode the information that comes back is an 8 bit binary field for...
0
7125
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
7208
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...
1
6890
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...
0
7379
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...
0
5464
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,...
1
4915
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...
0
1423
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 ...
1
657
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
292
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...

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.