February 2006 - Posts

LOL

Check this out:

http://rrrrrrrrrrrrrnnnnnnnnnnhhhh.blogspot.com/
with 1 Comments

CZ Stats is up again

CZ Stats have been down for a while, but all the bugs are fixed and it should work perfectly. Please take a look at it at http://www.czstats.com.
with 0 Comments

How to show an image from SQL Server database

First of all you need a field in your database with Image as datatype. Then use this code to show an image:

MemoryStream stream = new MemoryStream();
SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["YourConnection"].ConnectionString);
try
{
connection.Open();
SqlCommand command = new SqlCommand("SELECT [image] FROM tblTable WHERE id = 12345", connection);
byte[] image = (byte[])command.ExecuteScalar();
stream.Write(image, 0, image.Length);
Bitmap bitmap = new Bitmap(stream);
Response.ContentType = "image/gif";
bitmap.Save(Response.OutputStream, ImageFormat.Gif);
}
finally
{
connection.Close();
stream.Close();
}

Good luck. :)
with 0 Comments