日期:2014-05-17 浏览次数:21297 次
Random r = new Random();
int ID = r.Next();//设置初始帐号
int balance = 0;
string str1 = textBox1.Text;
string str2 = textBox2.Text;
string ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;data source=D:\\Bank.mdb";
OleDbConnection con = new OleDbConnection(ConStr);
con.Open();
if (con.State == ConnectionState.Open)
MessageBox.Show("连接成功!", "数据库状态信息");
else
MessageBox.Show("ERROR!", "数据库状态信息");
string sql = "insert??Bank(账号,姓名,密码,余额) VALUES('"+ID+"','"+str1+"','"+str2+"','"+ balance+"')";
OleDbCommand cmd = new OleDbCommand(sql, con);
cmd.ExecuteNonQuery();
cmd.Dispose();
con.Close();