I use SQL Server to build my database and SqlDataReader to read data from it.
command.Connection = cn;
command.CommandText = "SELECT * FROM test";
SqlDataReader rd = command.ExecuteReader();
while(rd.Read())
{
double d = (double) rd.GetValue(0);
}
The column (0) I am trying to get value from is a 'float' type and has value '3.5' . As mapping data type from this MSDN link, the type of the object returned by rd.GetValue(0) must be 'double'. But the code above returns to variable 'd' value '0.0'. I tried this line:
double d = Convert.ToDouble(rd.GetValue(0));
But it still returns '0.0' to variable 'd'.
I tried searching on Google and StackOverflow but there is no result.
What am I missing? Help me!
>) like a two-demensional array so that I could reuse it mutiple times.
– Phạm Thành Nov 23 '17 at 13:55