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?
As AkPosted Oct 9, 2020, 4:12 AM
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?
Nisha RegilPosted Oct 9, 2020, 3:44 AM
Jignesh KumarPosted Oct 9, 2020, 3:09 AM
Sachin SinghPosted Oct 9, 2020, 3:03 AM
As AkPosted Oct 9, 2020, 2:49 AM
Mageshwaran RPosted Oct 9, 2020, 2:48 AM
Sachin SinghPosted Oct 9, 2020, 2:38 AM