码迷,mamicode.com
首页 > 数据库 > 详细

OleDbCommand 的用法

时间:2016-09-28 01:27:05      阅读:251      评论:0      收藏:0      [点我收藏+]

标签:

OleDbConnection con=new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; data source=data.mdb");
con.Open();
OleDbCommand dc=new OleDbCommand("select name from us where id=2", con);
textBox1.Text=dc.ExecuteScalar().ToString();

OleDbConnection con=new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; data source=data.mdb");
con.Open();
OleDbCommand dc=new OleDbCommand("insert into us (name) values (11)", con);
dc.ExecuteNonQuery();
con.Close();


string us=textBox2.Text;
string pa=textBox1.Text;
OleDbConnection con=new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; data source=data.mdb"); 
OleDbCommand oldC=new OleDbCommand("insert into users (username, userpassword) values (@username, @userpassword)", con);
oldC.Parameters.Add("@username", us);
oldC.Parameters.Add("@userpassword", pa);
con.Open();
oldC.ExecuteNonQuery();
con.Close();
MessageBox.Show("Register successful!");
this.Dispose();

OleDbCommand 的用法

标签:

原文地址:http://www.cnblogs.com/zhangruifeng/p/5914835.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!