Add a row to datatable

G

Guest

Hi, i got a datatable from the database with alot of ID numbers (thats the
only thing in the datatable).

Now i want to make a row and add another number to that row and insert it
into the datatable at x position.

like:
sql = "select id from mytable";
myadap.commandtext = sql;
myadap.fill(mTable);

now mtable contains all of the ids, now i want to
DataRow mRow;
mRow.text = "55";
mTable.Rows.Add(mRow, pos);

I am using c#
 
G

Guest

You should use the InsertAt method which takes a postion paramter rather than
the Add method which just stick it at the end.

e.g.

mTable.Rows.InsertAt(mRow, pos);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top