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?

Mageshwaran RRank #411 · 6.1K reputationPosted Oct 8, 2020, 10:48 PM EDT
As Ak74 reputationPosted Oct 8, 2020, 10:49 PM EDT
Jignesh KumarRank #91 · 22.9K reputationPosted Oct 8, 2020, 11:09 PM EDT
Nisha RegilRank #1,956 · 748 reputationPosted Oct 8, 2020, 11:44 PM EDT
As Ak74 reputationPosted Oct 9, 2020, 12:12 AM EDT
The data displayed for Start_Range and End_Range is System.Byte[].
How can i solve this issue to get the correct value from the database?
Sachin SinghRank #66 · 26.2K reputationPosted Oct 8, 2020, 10:38 PM EDT
Sachin SinghRank #66 · 26.2K reputationPosted Oct 8, 2020, 11:03 PM EDT