By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,783 Members | 1,347 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,783 IT Pros & Developers. It's quick & easy.

copy 1 dimensional to 2 dimensional array with actual int values

P: n/a
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)

May 11 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
After even Index number add new row to your table and so on.
No need to get 2-D array
SA

"j-in-uk" <je******@gmail.com> wrote in message
news:11*********************@j33g2000cwa.googlegro ups.com...
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)

May 12 '06 #2

P: n/a
Hi,

Can you give me the code for that line pls.......
thanks

May 12 '06 #3

P: n/a
kh
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

May 12 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.