如何将行添加到现有数据表
我的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 C# 中,您可以执行与此类似的操作:
当然,此时表本质上是空的,但如果您的数据表来自数据库,那么它已经具有架构,并且新行将与其架构匹配。
In C# you can do something similar to this:
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.