Using the BLOB datatype

5 pts.
Tags:
BLOB
Oracle development
IT HAS BEEN CLEARED THAT TO INSERT THE IMAGES INTO ORACLE DATABASE, A COLUMN WITH DATATYPE BLOB HAS TO BE CREATED IN THE TABLE, PLEASE TELL ME HOW TO INSERT AND RETRIEVE THE IMAGE INTO AND FROM THE DATABASE RESPECTIVELY. THANKS, SIMRAN.

Answer Wiki

Thanks. We'll let you know when a new response is added.

SIMRAN,

The only time I have to write Binary objects to the db is through an application and not via SQL. I have a web application that allows users to enter in pictures (of themselves which can be very funny to review). The developers retrieve and write to it using a method that does this:

public byte[] GetPhoto(string userId)
{
byte[] photo = null;
StringBuilder sbSql = new StringBuilder();
sbSql.Append(“SELECT PHOTOS.PHOTO, users.id”);
sbSql.Append(“FROM PHOTOS INNER JOIN “);
sbSql.Append(” users ON PHOTOS.ID = users.ID “);
sbSql.Append(” WHERE (users.ID = @:id) “);

DbCommand cmd = GetSqlStringCommand(sbSql.ToString());

AddInParameter(cmd, “id”, DbType.String, userId);
using (IDataReader idr = ExecuteReader(cmd))
{
while (idr.Read())
{
photo = (byte[])idr[“PHOTO”>;
}
}

return photo;

}

Hope this helps.

rdano

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following