当前位置:文档之家› C#连接ACCESS数据库的一个登陆程序源代码

C#连接ACCESS数据库的一个登陆程序源代码

.Data;

using System.Drawing;

using System.Lin;

using System.Text;

using System.Windows.Forms;

using System.Data.OleDb;



namespace MyAccessConnectionTest

{

public partial class Form1 : Form

{



Form2 ShowInformationForm;

public Form1()

{

InitializeComponent();

}



private void button1_Click(object sender, EventArgs e)

{

//接收文本框中输入的用户信息

string UserIDSave=textBox1 .Text.ToString () ;

string UserKeySave=textBox2 .Text.ToString () ;



//创建连接access数据库的连接字符串

string ConnectionWords = @&uot;Provider=Microsoft.Jet.OLEDB.4.0;Data

Source=C:\Users\learic\Desktop\MyAccessConnectionTest.mdb&uot;;



//连接数据库

OleDbConnection MyAccessConnect = new OleDbConnection(ConnectionWords);

//打开数据库

MyAccessConnect.Open();



//数据库命令字符串



string CommandString = string.Format(&uot;SELECT UserID,UserKey FROM UserLogTable WHERE (https://www.doczj.com/doc/8c7198466.html,erID='{0}') AND (https://www.doczj.com/doc/8c7198466.html,erKey='{1}')&uot;, UserIDSave, UserKeySave);

//string CommandString = &uot;SELECT UserID,UserKey FROM UserLogTable WHERE UserID=&uot; + UserIDSave + &uot; AND UserKey=&uot; + UserKeySave + &uot;&uot

相关主题
相关文档 最新文档