This is not the exact solution for your problem but I hope this will help you to get some idea to solve your problem.
This is the SP I used for this sample
CREATE proc [dbo].[ReadAllImageIDs] as
SELECT ImageID FROM ImageData
GO
below is the loadImageIDs method
private void loadImageIDs()
{
#region Load Image Ids
SqlConnection con = new SqlConnection(DBHandler.GetConnectionString());
SqlCommand cmd = new SqlCommand("ReadAllImageIDs", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter adp = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
try
{
if (con.State == ConnectionState.Closed)
con.Open();
adp.Fill(dt);
if (dt.Rows.Count > 0)
{
cmbImageID.DataSource = dt;
cmbImageID.ValueMember = "ImageID";
cmbImageID.DisplayMember = "ImageID";
cmbImageID.SelectedIndex = 0;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
if (con.State == ConnectionState.Open)
con.Close();
}
#endregion
}
for more details
Storing and Retrieving Images from SQL Server Using Strored Procedures and C#.net[
^]
Thanks