標籤:ext com dbus ati trim 連結 本地 總結 mode
最近做了一個上位機項目,遇見了很多問題點,一直沒有時間總結。現在項目告一段落,上來總結一下,都是通過網路尋找資料解決的。再次感謝那些前輩,再次做一下記錄,方便同行參考,也方便自己以後查看。
介面如下:
一:問題點,做使用者登入時出現:“”未在本機電腦上註冊 Microsoft.ACE.OLEDB.12.0 提供者“” 的彈框報錯。
下面是代碼
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using MoudelII;namespace Template{ public partial class frmLogin : Form { public frmLogin() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { try { string user = textBox_UserName.Text.Trim(); string pwd = textBox_Password.Text.Trim(); if ((user == "") || (pwd == "")) { MessageBox.Show("使用者名稱或密碼錯誤!"); return; } //string strconn = "Provider=Microsoft.ACE.OLEDB.4.0;Data Source=" + Application.StartupPath + @"\db_UserMsg.accdb"; //modAccess access = new modAccess(strconn); string sql = "select * from tbUserInfo where UserName=‘" + user + "‘ and Password=‘" + pwd + "‘"; DataTable dt = ComData.dbUser.ExecuteDataTable(sql); if (dt.Rows.Count > 0) { ComData.UserLevel = Convert.ToInt32(dt.Rows[0]["UserLevel"]); ComData.UserName = dt.Rows[0]["UserName"].ToString().Trim(); MessageBox.Show("登入成功!"); this.Hide(); } else { MessageBox.Show("使用者名稱或密碼錯誤!"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void textBox_Password_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == ‘\r‘) { button1_Click(sender, e); } } }}
public static modAccess dbUser = new modAccess("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Application.StartupPath + @"\db_UserMsg.dat
使用者和密碼,儲存到 :
db_UserMsg.dat 的檔案裡面。
在開發的電腦上無報錯,但拷到裝置上位機裡面就會報:“”未在本機電腦上註冊 Microsoft.ACE.OLEDB.12.0 提供者“”。的錯誤提示。
二:解決方案:https://q.cnblogs.com/q/43682/ 查到這位前輩的部落格,通過他的方法即可解決,再次表示感謝。
下載連結地址
http://download.microsoft.com/download/7/0/3/703ffbcb-dc0c-4e19-b0da-1463960fdcdb/AccessDatabaseEngine.exe
將下載的
軟體安裝到電腦即可解決。
未在本機電腦上註冊 Microsoft.ACE.OLEDB.12.0 提供者