根据http://msdn.microsoft.com/en-us/library/office/aa211091(v=office.11).aspx,则MS Jet数据库引擎不具有“NUMBER”的数据类型;然而,这就是我在我查询表的MS Access的设计视图中看到 - 我正在检索机智的查询是“一把手”的数据类型的第一列的MS Access“Number”类型对应哪个C#数据类型?
数据类型。
我有了这个代码,打破,无论是当我尝试将该值转换为int32和双:
// A set comprised of two columns are returned from a query in cmd
using (OleDbDataReader oleDbD8aReader = cmd.ExecuteReader())
{
while (oleDbD8aReader != null && oleDbD8aReader.Read())
{
//var accountID = oleDbD8aReader.GetString(0); // <-- this fails (it's a number, not a string)
//var accountID = oleDbD8aReader.GetInt32(0); // <-- this also fails!
var accountID = oleDbD8aReader.GetDouble(0); // <-- as does this!
var deptName = oleDbD8aReader.GetString(1);
. . .
}
}
为什么它不能转换为字符串,int或double?我应该把它转换成什么呢?
你试过考虑看看'oleDbD8aReader [“字段名”]的GetType()',看看是否能拥有任何线索,返回什么? –
正如老猫在“Never Cry Wolf”中所说的,“好主意!”它说Int16。 –