English 中文(简体)
数据交换器无需打开 d接线?
原标题:DataAdapter does not need to make db connection open?

I try to use DataAdapter in C#.net. and still I do not understand something about DataAdapter.

我阅读了许多关于数据应用和数据检索的文章和博客。

我的理解是,数据Adapter将在必要时自动开放和关闭数据库。

But,

//conn.Open();
AdsDataAdapter da;
da = new AdsDataAdapter("Select * from Test", conn);
AdsCommandBuilder cb;
cb = new AdsCommandBuilder(da);

DataSet ds = new DataSet();
da.Fill(ds, "Test");

DataRow newrow = ds.Tables["Test"].NewRow();
newrow["Name"] = "How about";
ds.Tables["Test"].Rows.Add(newrow);
da.Update(ds, "Test");

当我操作上述法典时,我收到一个错误的信息,即“必须开放”

为什么适应者不能自动开放联系?

并且,我希望插入数据,以插入“共同点”(为这一试验,我打开了链接)。

da.InsertCommand = new AdsCommand("INSERT INTO test (NAME) values( Insert Test #1 )", conn);
//da.InsertCommand.ExecuteNonQuery(); // it works
da.Update(ds,"Test"); //but it does not works.

许多使用适应器的例子。 更新,但对于我来说,它并不发挥作用:

No error and nothing inserted.

并且使用。 插入Command.ExecuteNonQuery();相反,它正在更新。

what am I doing wrong?

感谢!

最佳回答
问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签