开发者

How to add row to EXISTING Datatable

开发者 https://www.devze.com 2023-02-01 03:47 出处:网络
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

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开发者_StackOverflow中文版 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消