TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
matthew knudsen
NA
2
4.3k
simple array problem
Sep 15 2010 1:03 PM
okay this is what would seem to be a simple problem... but I am stumped. I am taking multiple columns from an sql db and putting into an object array. Then I put all the objects in a string array. I would like to assign each value in the string array to a variable.
here is my load_array method
private void load_array()
{
/* create connection */
SqlConnection conn = new SqlConnection("Data Source=192.168.168.134\\MSSQLLITMARK;Initial Catalog=Litmark;User id=sa;password=**************;");
SqlCommand cmd = new SqlCommand("SELECT Images_ID FROM tbImages WHERE Images_CarID = @car_id", conn);
cmd.Parameters.AddWithValue("@car_id", car_id);
try
{
/* array list to hold data */
ArrayList list = new ArrayList();
conn.Open();
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
object[] values = new object[reader.FieldCount].ToArray();
reader.GetValues(values);
list.Add(values);
}
/* now convert to a string array */
foreach (object[] row in list)
{
string[] details = new string[row.Length];
int columnIndex = 0;
foreach(object column in row)
{
details[columnIndex++] = Convert.ToString(column);
}
/* Assign the itmes in the string array to picture boxes. */
/* I have global variables picID1 - picID5 that I would like to assign the data in string[] */
for (int i = 0; i < details.Length; i++)
{
MessageBox.Show("array : " + details[i]);
}
}
}
catch (Exception ex)
{
MessageBox.Show("error: " + ex.Message.ToString());
}
}
Reply
Answers (
1
)
hadling multiple forms
WebRequest.GetRequestStream() -- error This stream does not support seek operations.