更新Access数据库 [英] Updating an Access Database

查看:89
本文介绍了更新Access数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何帮助将不胜感激!!



c#新手,并尝试做一些基本的数据库编辑/更新/添加等。



似乎无法将任何数据更新到我的表格中。

我正在获取数据并能够显示和逐步通过。好像某个地方有一个只读属性!!!





Any help would be appreciated!!

New to c# and trying to do some basic database edit / update / add etc.

Cant seem to get any data to update into my table.
I am picking up the data and able to display and step thru. Its as if there is a read only attribute somewhere !!!


private void button1_Click(object sender, EventArgs e)
        {
            string connectionString = dbProvider + dbSource;
            string queryString=sql;
            DataSet dataSet = new DataSet();
            using (OleDbConnection connection = new OleDbConnection(connectionString))
            {
                connection.Open();
                OleDbDataAdapter adapter = new OleDbDataAdapter();
                adapter.SelectCommand = new OleDbCommand(queryString, connection);
                OleDbCommandBuilder builder = new OleDbCommandBuilder(adapter);
                adapter.Fill(dataSet);

                string st = "Dizzy blond";

                dataSet.Tables[0].Rows[1].ItemArray[2] = st;

                // Code to Modify

                adapter.UpdateCommand = builder.GetUpdateCommand();
                adapter.Update(dataSet);
            }

推荐答案

尊敬的会员11008177,





如上所示你已经展示了 COMMANDBUILDER 的用途。



使用CommandBuilder试试这个:

http://www.homeandlearn.co.uk/csharp/csharp_s12p9.html [< a href =http://www.homeandlearn.co.uk/csharp/csharp_s12p9.htmltarget =_ blanktitle =New Window> ^ ]







但我建议不要使用 COMMANDBUILDER 尝试使用自己的ADO.NET代码。试试,下面这个提及链接。





http://altafhussainbd.wordpress.com/tag/crud-operation-in-c-and-access/ [ ^ ]





https://www.planet-source-code.com/vb/ scripts / ShowCode.asp?txtCodeId = 4291& lngWId = 10 [ ^ ]





ADO。 NET

http://www.dbtutorials。 com / advanced / access-db-ado-net-csharp / [ ^ ]



http://www.c-sharpcorner.com/uploadfile/mimrantaj/connect-to-access-database-in- C-Sharp-and-ado-net / [ ^ ]



为什么我告诉你(会员11008177)因为如果你使用自己的代码。您将对代码进行更多控制,而不是命令构建者。



您需要随时与我联系。



谢谢。

Manoj Kalla
Dear Member 11008177,


As above you had shown uses of COMMANDBUILDER things.

With CommandBuilder try this:
http://www.homeandlearn.co.uk/csharp/csharp_s12p9.html[^]



But I suggest don't use COMMANDBUILDER try use your own ADO.NET Code.Try, this below mention link.


http://altafhussainbd.wordpress.com/tag/crud-operation-in-c-and-access/[^]


https://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=4291&lngWId=10[^]


ADO.NET
http://www.dbtutorials.com/advanced/access-db-ado-net-csharp/[^]

http://www.c-sharpcorner.com/uploadfile/mimrantaj/connect-to-access-database-in-C-Sharp-and-ado-net/[^]

Why I am telling you (Member 11008177) because If you use your own code. You will having more control on code rather commandbuilder.

Any fruther assist you require feel free to contact me.

Thank You.
Manoj Kalla


这篇关于更新Access数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆