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
-
- 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?