通过textBox更新MSAccess [英] Updating MSAccess through textBox
本文介绍了通过textBox更新MSAccess的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用通过C#中的文本框输入的数据来更新/修改/替换数据库(MS Access)中的特定单元格(行i,列j).请帮助
how to update/modify/replace a particular cell(Row i,Column j) in a database (MS Access)with the data entered through a textboxe in C# .please help
推荐答案
假定您已经与Access数据库建立了连接,并且位于:
Assuming you already have your connection to the Access database and where:
OleDbConnection AccessCon = new OleDbConnection();
OleDbCommand cmd = default(OleDbCommand);
OleDbDataReader reader = default(OleDbDataReader);
string cmdUpdate = null;
然后是以下内容:
Then something in the line of:
cmdUpdate = "UPDATE TABLE_NAME " + "SET COLUMN_j = '" + TextBox1.Text + "' " + "WHERE ID(ROW_i) = " + TextBox2.Text;
cmd = new OleDbCommand(cmdUpdate);
try {
cmd.Connection = AccessCon;
cmd.CommandType = CommandType.Text;
reader = cmd.ExecuteReader();
} catch (Exception ex) {
MessageBox.Show(ex.Message);
}
reader.Dispose();
PS:我不是C#的明星,因此以上内容是从vb.net转换而来的.
PS: I''m not a star at C#, thus the above is converted from vb.net.
这篇关于通过textBox更新MSAccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文