468,268 Members | 1,691 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,268 developers. It's quick & easy.

Fetching multiple images from database

Hi to All Senior's,
I am working in Asp.net with C#. I am newbie in C#. So i want to fetch mutiple images from database .Database i am using is Sql Server.
For this i code:

//get the image id from the url
string Imagename = DropDownList1.SelectedItem .Text ;
//string Imagename = Request.QueryString["DropDownList1.SelectedItem.Value"];

//build our query statementworkstation id=SOFTWARE3;packet size=4096;integrated security=SSPI;data source=SOFTWARE3;persist security info=True;initial catalog=farmergroup
string sqlText = "SELECT Image FROM images WHERE Name='"+Imagename+"'";

SqlConnection connection = new SqlConnection("workstation id=SOFTWARE3;packet size=4096;integrated security=SSPI;data source=SOFTWARE3;persist security info=True;initial catalog=farmergroup");
SqlCommand command = new SqlCommand( sqlText, connection);

//open the database and get a datareader
connection.Open();
SqlDataReader dr;
dr = command.ExecuteReader();
while (dr.Read()) //yup we found our image
{
//Response.ContentType = dr["img_contenttype"].ToString();
Response.BinaryWrite((byte[])dr["Image"]);
}
connection.Close();

}
}
This is fetching only one image.but i want fetch more image.Please check it.
Please help me as i am new in c#.
Thanks & Regards.
Punit Shrivastava.
Nov 6 '07 #1
0 1092

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Jon | last post: by
3 posts views Thread by Arun | last post: by
5 posts views Thread by randomtalk | last post: by
22 posts views Thread by Sandman | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kermitthefrogpy | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.