I have a database (sql server 2008) and I am working with C # in visual studio 2010.
I want to establish a connection with my db. I wrote the code for this as follows:
SqlConnection mySqlConnection = new SqlConnection ("Data Source=servername\\SQL2008; Initial Catalog=MyData;UID=MyID;PWD=mypassword;"); SqlCommand mySqlCommand = mySqlConnection.CreateCommand(); mySqlCommand.CommandText = "SELECT image_column FROM images_table "; mySqlConnection.Open(); SqlDataReader productsSqlDataReader = mySqlCommand.ExecuteReader();
I do not know how to move on. I mean, how do I retrieve a column from the reader after completing the above statements? I also need to go through the entire column in a row after row and convert each image into an IContent element. Do I have to write my own converter for this, or is there any .NET class that does this already?
Here is the script. I have a table with 20 columns, one of which is image_column. This column is ONLY a column in which there are images stored as binary data. The remainder columns are ordinary integers (its dimensional value) and strings (its name, location, etc.) Associated with this particular image. Hope this is clear now.
Thanks.
source share