【发布时间】:2017-10-25 05:05:39
【问题描述】:
我想从 .mdb 获取一些数据,但在 WinXP 机器上出现异常。已经安装了 MDAC 2.8。有没有办法在不改变数据库类型的情况下解决我的问题?获取数据的方法:
private void GetDatafromDB(){
int counter = 0;
string _sql = "select * from template where 1=1";
OleDbDataReader reader = ldb.ReadList(_sql);
while (reader.Read())
{
if (reader[1] is DBNull)
continue;
this.t0 = reader[0].ToString();//autoid
this.t1 = reader[1].ToString();//real name
this.t2 = reader[2].ToString();//userid
this.t3 = reader[3].ToString();//fingerindex
this.t4 = reader[4].ToString();//rights
this.t5 = reader[5].ToString();//base64 template_9
//int autoid = (int)reader[0];
byte[] tmp = Convert.FromBase64String(this.t5);
zkfp2.DBAdd(mDBHandle, Int32.Parse(t3), tmp);
counter++;
}
textTips.AppendText("Loaded "+ counter +" fingerprints \r\n");
}
例外:
**************异常文本**************
System.Data.OleDb.OleDbException:选择的整理顺序不是 操作系统支持。在 System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult 小时)在 System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams,对象和执行结果)在 System.Data.OleDb.OleDbCommand.ExecuteCommandText(对象& 执行结果)在 System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior 行为,对象和执行结果)在 System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior 行为,字符串方法)在 System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior 行为) 在 System.Data.OleDb.OleDbCommand.ExecuteReader() 在 WindowsFormsApp1.LocalDb.ReadList(String SQL) 在 c:\用户\用户\桌面\指纹 WINxp\WindowsFormsApp1\LocalDb.cs:第 132 行 WindowsFormsApp1.Form1.GetDatafromDB() 在 c:\用户\用户\桌面\指纹 WINxp\WindowsFormsApp1\Form1.cs:第 362 行 WindowsFormsApp1.Form1.connDevice_Click(Object sender, EventArgs e) in c:\用户\用户\桌面\指纹 WINxp\WindowsFormsApp1\Form1.cs:第 354 行 System.Windows.Forms.Control.OnClick(EventArgs e) 在 System.Windows.Forms.Button.OnClick(EventArgs e) 在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs 事件) 在 System.Windows.Forms.Control.WmMouseUp(消息和 m,鼠标按钮 按钮,Int32 点击)在 System.Windows.Forms.Control.WndProc(Message& m) 在 System.Windows.Forms.ButtonBase.WndProc(Message& m) 在 System.Windows.Forms.Button.WndProc(Message& m) 在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(消息& m) 在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(消息& m) 在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
【问题讨论】:
-
您的表是否缺少唯一键索引?
-
@JohnWu 我只有一个带有唯一键索引的表 - ID
标签: c# .net ms-access windows-xp