Skip to content

Commit 272f8a0

Browse files
committed
Fixes #17
1 parent 42c4aab commit 272f8a0

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

src/System.Data.Jet/JetDataReader.cs

+19-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
using System;
22
using System.Data.Common;
33
using System.Text;
4-
using System.Threading;
5-
using System.Threading.Tasks;
64

75
namespace System.Data.Jet
86
{
@@ -106,7 +104,15 @@ public override decimal GetDecimal(int ordinal)
106104

107105
public override double GetDouble(int ordinal)
108106
{
109-
return Convert.ToDouble(_wrappedDataReader.GetValue(ordinal));
107+
object value = _wrappedDataReader.GetValue(ordinal);
108+
if (value is string)
109+
{
110+
byte[] buffer = Encoding.Unicode.GetBytes((string)value);
111+
double doubleValue = BitConverter.ToDouble(buffer, 0);
112+
return doubleValue;
113+
}
114+
else
115+
return Convert.ToDouble(_wrappedDataReader.GetValue(ordinal));
110116
}
111117

112118
public override System.Collections.IEnumerator GetEnumerator()
@@ -121,7 +127,15 @@ public override Type GetFieldType(int ordinal)
121127

122128
public override float GetFloat(int ordinal)
123129
{
124-
return Convert.ToSingle(_wrappedDataReader.GetValue(ordinal));
130+
object value = _wrappedDataReader.GetValue(ordinal);
131+
if (value is string)
132+
{
133+
byte[] buffer = Encoding.Unicode.GetBytes((string)value);
134+
float singleValue = BitConverter.ToSingle(buffer, 0);
135+
return singleValue;
136+
}
137+
else
138+
return Convert.ToSingle(_wrappedDataReader.GetValue(ordinal));
125139
}
126140

127141
public override Guid GetGuid(int ordinal)
@@ -188,7 +202,7 @@ public override T GetFieldValue<T>(int ordinal)
188202
if (typeof(T) == typeof(TimeSpan))
189203
return (T)(object)GetTimeSpan(ordinal);
190204
else if (typeof(T) == typeof(DateTimeOffset))
191-
return (T) (object) GetDateTimeOffset(ordinal);
205+
return (T)(object)GetDateTimeOffset(ordinal);
192206
else
193207
return base.GetFieldValue<T>(ordinal);
194208
}

0 commit comments

Comments
 (0)