TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
As Ak
NA
65
7.6k
Fetch a binary data from database
Oct 9 2020 2:15 AM
I've a list of hexadecimal value with a data type varbinary in the database. But when I run a query, nothing shown as a result.
The example of the hexadecimal value in the database:
0x10160000, 0x1016FFFF
0x10170000, 0x1017FFFF
This is my current code
//this string SNE will get the data from the text file string
SNE = data[
"End_Rg"
];
query =
"SELECT Start_Range, End_Range, Status FROM Range WHERE End_Range = '"
+ SNE +
"' "
;
sqlcmd =
new
SqlCommand(query, cnn);
readData = sqlcmd.ExecuteReader();
readData.Read();
Console.WriteLine(
"Start Range: {0}"
, readData[
"Start_Range"
]);
Console.WriteLine(
"End Range: {0}"
, readData[
"End_Range"
]);
Console.WriteLine(
"Status: {0}"
, readData[
"Status"
]);
Currently, I'm getting an error:
> System.InvalidOperationException: 'Invalid attempt to read when no data is present.'
Can I know what is the best way to fetch the binary data from the database?
Reply
Answers (
7
)
Pull API data with RestSharp and insert into SQLite
System.Byte[] displayed