Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7540283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:36:14+00:00 2026-05-30T07:36:14+00:00

Let’s say if I capture a screen shot. There is my code for it

  • 0

Let’s say if I capture a screen shot. There is my code for it

int sWidth = 1600, sHeight = 1200;

Bitmap B_M_P = Bitmap(sWidth, sHeight);

Graphics gfx = Graphics.FromImage((Image)B_M_P);
gfx.CopyFromScreen(0, 0, 0, 0, new Size(screenWidth, screenHeight));            

B_M_P.Save("img.jpg", ImageFormat.Jpeg);

instead of saving this to an Image, i wanna be able to send this to my SQL or MySQL and store them in the database as BLOB.

i know the LINQ as well to query the DB. What i don’t know is the intermediate portion.

  • What kind of Data Type will be used to INSERT in a BLOB column, my
    guess is it will be a Byte[]?

if it is a ‘Byte’, then the conversion is pretty easy.

ImageConverter imgc = new ImageConverter();
Byte[] temp = (byte[])imgc.ConvertTo(B_M_P,typeof(byte[]));

so that afterwards i can prepare my query

"INSERT INTO EMPLOYEE (pic) VALUES ('"+temp+"');"
  • If not then WHAT IS THE TYPE & HOW TO CONVERT
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T07:36:16+00:00Added an answer on May 30, 2026 at 7:36 am

    Your are correct that you just need to turn it in to a byte array. The datatype of your table should be VarBinary(max).

    Note that there is a Image datatype, but that datatype will be removed in a future version of Microsoft SQL Server, so Microsoft is recommending everyone switch to VarBinary for future compatibility.


    BLOBs and VarBinary(max) are the same thing. From Understanding VARCHAR(MAX) in SQL Server 2005

    To solve this problem, Microsoft introduced the VARCHAR(MAX),
    NVARCHAR(MAX), and VARBINARY(MAX) data types in SQL Server 2005. These
    data types can hold the same amount of data BLOBs can hold (2 GB) and
    they are stored in the same type of data pages used for other data
    types. When data in a MAX data type exceeds 8 KB, an over-flow page is
    used. SQL Server 2005 automatically assigns an over-flow indicator to
    the page and knows how to manipulate data rows the same way it
    manipulates other data types. You can declare variables of MAX data
    types inside a stored procedure or function and even pass them as
    variables. You can also use them inside string functions.

    Microsoft recommend using MAX data types instead of BLOBs in SQL Server 2005. In fact, BLOBs are being deprecated in future releases of
    SQL Server.

    That Image data type I mentioned at the top is a example of the old-style BLOB datatype.


    Here is a example of how the code should be

    using(var cmd = SqlCommand("INSERT INTO EMPLOYEE (pic) VALUES (@pic);", connection)
    {
        cmd.Parameters.Add("@pic", temp);
        cmd.ExecuteNonQuery();
    }
    

    However there are some Gotchas if you are working with large files, see this SO answer and its links for in depth look at storing large data objects in the database.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say there is a graph and some set of functions like: create-node ::
Let's say I have this code: <p dataname=description> Hello this is a description. <a
Let say I have some code HTML code: <ul> <li> <h1>Title 1</h1> <p>Text 1</p>
Let's say the rule is as follows: .largeField { width: 65%; } Is there
Let's say there is a list of List<UInt32> Thus, : 12|12 23|33 33|22 11|22
Let's say that I have classes like this: public class Parent { public int
Let's say i have this block of code, <div id=id1> This is some text
Let's say I wanted all nodes whose parent(s) matched some certain condition. Is there
Let's say you create a wizard in an HTML form. One button goes back,
Let's say I'm building a data access layer for an application. Typically I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.