我想从 .mdb 获取一些数据,但我在WinXP机器上遇到异常。安装了MDAC 2.8 alrdy。有没有办法解决我的问题而不改变数据库类型?获取数据的方法:
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 hr)at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams,Object& executeResult)at System.Data.OleDb.OleDbCommand.ExecuteCommandText(对象&安培; executeResult)at System.Data.OleDb.OleDbCommand.ExecuteCommand(的CommandBehavior 行为,对象& executeResult)at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(的CommandBehavior 行为,String方法)at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior) 在System.Data.OleDb.OleDbCommand.ExecuteReader()at WindowsFormsApp1.LocalDb.ReadList(String SQL)in 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)at System.Windows.Forms.Button.OnClick(EventArgs e)at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)at at System.Windows.Forms.Control.WmMouseUp(Message& m,MouseButtons 按钮,Int32点击)at System.Windows.Forms.Control.WndProc(Message& m)at System.Windows.Forms.ButtonBase.WndProc(Message& m)at System.Windows.Forms.Button.WndProc(Message& m)at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) 在System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)在System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd,Int32) msg,IntPtr wparam,IntPtr lparam)
答案 0 :(得分:0)
问题是目标计算机有另一种系统语言,而另一种语言创建了.mdb文件。在目标机器上创建新数据库 - 解决了我的问题。
来源 - http://www.cnblogs.com/zoupeiyang/archive/2009/03/11/1408741.html