copy 1 dimensional to 2 dimensional array with actual int values

J

j-in-uk

Hi,
I have a table with 2 columns and a one dimensional string array.
I need to copy the string array to the table but I think I have to
convert my string array to a 2dimensional array first with an
incremental id inorder to add to table. any suggestions how to? thanks

DataTable dtContinent = ds.Tables.Add("Continent");
DataColumn dtContinent_ID = dtContinent.Columns.Add("ID", typeof(int));
DataColumn dtContinent_Name = dtContinent.Columns.Add("Name",
typeof(string));
\\string of names
_albumList = FileManager.GetAlbumNames(_photosPath);
\\error cos has only one col
dtContinent.Rows.Add(_albumList)
 
M

MSDN

After even Index number add new row to your table and so on.
No need to get 2-D array
SA
 
G

Guest

for(int albumIdx = 0; albumIdx<_albumList.Length; ++albumIdx)
dtContinent.Rows.Add(new object[] {albumIdx, _albumList[albumIdx]});

alternatively you can make dtContinent_ID and AutoIncrement column and pass
null as the first value in the item array.

kh
 

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

Top