如何在命令构建器中使用delete命令 [英] how to use delete command with command builder

查看:58
本文介绍了如何在命令构建器中使用delete命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在.Net 3.5中创建了一个程序,我想在Ado.NET中使用delete命令,(在sql server 2005上的后端)。

i不知道如何使用这个命令。

请问有人帮我编码吗?



例子..插入命令



I m making a program in .Net 3.5, and i want to use delete command in Ado.NET, (backend on sql server 2005).
i dont know how exactly to use this command.
Pls can someone help me with coding?

Example.. insert command

private void button4_Click(object sender, EventArgs e)
       {
           cm = new SqlCommandBuilder(da);
           MessageBox.Show(cm.GetInsertCommand().ToString());
           da.Update(ds.Tables[0]);
           MessageBox.Show("updated");

       }







删除命令....





{告诉我}




delete command....


{ tell me }

推荐答案

以下是详细信息您需要知道:

SqlCommand类 [ ^ ]

与链接中的示例一样,只需按照您希望的方式更改SQL字符串。在命令中设置它。可能是插入,更新或删除。执行它。



阅读本课程,了解所有基础知识,包括以下示例:

ADO.NET [ ^ ]



更新:

提供全部细节/链接,如果你还在等待答案,可能是你没有正确地提出你的问题。

只是假设一些东西,根据你的问题可以适合什么,看看这个,如果它有帮助:

使用CommandBuilder删除数据 [< a href =http://www.java2s.com/Tutorial/CSharp/0560__ADO.Net/DeleteDatausingCommandBuilder.htmtarget =_ blanktitle =New Window> ^ ]
Here are the details that you need to know:
SqlCommand Class[^]
As in the sample in link, just change the SQL string the way you want to. Set it in the command. May be it is Insert, Update or a Delete. Execute it.

Read this for learning all basics with samples here:
ADO.NET[^]

UPDATE:
After providing all the details/links, if you are still waiting for an answer, might be you are not putting your question properly.
Just assuming few things and based on what can fit in your question, look at this, if it helps:
Delete Data using CommandBuilder[^]


Common.cmdbuilder = new System.Data.SqlClient.SqlCommandBuilder(Common.StockPurchase_Part);
                           Common.StockPurchase_Part.DeleteCommand = Common.cmdbuilder.GetDeleteCommand();
                           Common.StockPurchasePartDataset.Tables[0].Rows[0].Delete();
                           Common.StockPurchase_Part.Update(Common.StockPurchasePartDataset.Tables[0]);







标记数据集并调用Update




Mark the dataset and call Update


这篇关于如何在命令构建器中使用delete命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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