c#对access数据库的访问!!!
namespace WindowsApplication2
{
public partial class Form1 : Form
{
System.Data.OleDb.OleDbConnection conn;
System.Data.OleDb.OleDbCommand comm;
DataTable tbl;
System.Data.OleDb.OleDbDataAdapter myadp;
System.Data.OleDb.OleDbDataReader myreader;
public Form1()
{
InitializeComponent();
string strConnection = "Provider=Microsoft.Jet.OleDb.4.0;";
strConnection += @"Data Source=H:\\exam.mdb";
conn = new OleDbConnection(strConnection);
comm = new OleDbCommand();
comm.Connection = conn;
comm.CommandText = "select * from exam";
myadp = new OleDbDataAdapter(comm);
tbl = new DataTable();
}
private void richTextBox1_TextChanged(object sender, EventArgs e)
{
conn.Open();
myadp.Fill(tbl);
conn.Close();
}
private void button1_Click(object sender, EventArgs e)
{
richTextBox1.AppendText(tbl.Rows[0][0].ToString());
}
}
}
红色部分为出错的地方.以上是c#对access数据库的查询语句,并让其查询出的内容在richtextbox1中显示;
还请各位帮帮忙,谢啦
另外还请大哥大姐给出对数剧库的增删改方法:
答完给分!!!