Click here to Skip to main content
14,608,247 members
Rate this:
Please Sign up or sign in to vote.
See more:
Am developing a project to capture an finger print image from the biometric device and store it in database. My question is "Is it good to store the image directly into the database or store it in file and store the path of the file into the database." Please send the code to both cases.
Posted
Rate this:
Please Sign up or sign in to vote.

Solution 3

It is useful if you store the images in a folder and store only path of that images in sql server database.
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

hi you should define a field varbinary(MAX) in database
then use this code
FileStream file = new FileStream(openFileDialog1.FileName, FileMode.Open, FileAccess.Read);
            BinaryReader str1 = new BinaryReader(file);
            byte[] bit = str1.ReadBytes(Convert.ToInt32( file.Length));
            SqlConnection connection = new SqlConnection("server=(local);database=test;integrated security=true");
            connection.Open();
            SqlCommand command = new SqlCommand();
            command.Connection = connection;
            command.CommandType = CommandType.Text;
            command.Parameters.AddWithValue("@Photo",bit);
            command.CommandText = "INSERT INTO image1(pic) VALUES (@Photo)";
            command.ExecuteNonQuery();
            connection.Close();
   
Comments
Anuradha Salim 9-Nov-12 12:30pm
   
Can you explain the code for retrieving image from the database sqlserver 2008?
Rate this:
Please Sign up or sign in to vote.

Solution 1

Ideally you should not store the entire image into database. Store only path of that image.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100