如何将行添加到现有数据表

发布于 2024-10-09 19:50:59 字数 315 浏览 0 评论 0原文

我的 Visual Basic 2010 Express 解决方案中有一个 sql 数据库 (agentroster.sdf),并且我能够使用数据表创建数据源 (AGENT_ROSTER)。据我所知,所有这些都有效。

但是,我尝试从 ROSTER.xaml.vb(与数据库位于同一项目中)向此现有数据表(以及数据库)添加新行。我还需要删除记录,并将记录的值加载到一组变量中,这些变量稍后将在更改后写回。该系统对于我的特定项目是必要的。

但是,我无法弄清楚如何在此现有数据表中创建新行。我已经确认了连接和所有内容,并且我不想在现有连接的基础上创建一个全新的连接。

帮助?

I have an sql database (agentroster.sdf) in my Visual Basic 2010 Express solution, and I have been able to create a data source (AGENT_ROSTER), with the datatable. All this works, as far as I can tell.

However, I am trying to add a new row to this existing datatable (and thus, database) from ROSTER.xaml.vb, which is in the same project as the database. I will also need to delete records, and load a records' values into a set of variables, which will later be written back after changing. This system is necessary for my particular project.

However, I cannot figure out how to create a new row in this EXISTING datatable. I've already confirmed the connections and everything, and I don't want to have to create an entirely new connection on top of the existing one.

Help?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

滥情哥ㄟ 2024-10-16 19:50:59

在 C# 中,您可以执行与此类似的操作:

    var table = new DataTable();
    var row = table.NewRow();
    table.Rows.Add(row);

当然,此时表本质上是空的,但如果您的数据表来自数据库,那么它已经具有架构,并且新行将与其架构匹配。

In C# you can do something similar to this:

    var table = new DataTable();
    var row = table.NewRow();
    table.Rows.Add(row);

Of course table is essentially empty at this point but if your datatable came from a database then it has schema already and the new row will match it's schema.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文