Inserting Picture Into Database

May 28, 2010

I am inserting a picture into a database, using the following code.

strFileType = Path.GetExtension(filImage.PostedFile.FileName).ToLower();
switch (strFileType)
{
case ".gif":
strMimeType = "image/gif";
break;
case ".jpg":
case ".jpeg":
case ".jpe":
strMimeType = "image/jpeg";
break;
case ".png":
strMimeType = "image/png";
break;
}
//Store the content length
int iDocLength = filImage.PostedFile.ContentLength;
byte[] bDocBuffer = new byte[iDocLength];
//Get stream object
Stream streamImage;
streamImage = filImage.PostedFile.InputStream;
streamImage.Read(bDocBuffer, 0, iDocLength);
cmPerson.CommandText = "INSERT INTO photos VALUES(@referenceid, @image, @imgtype)";
cmPatient.Parameters.AddWithValue("@referenceid", iPersonID.ToString("000000"));
cmPerson.Parameters.AddWithValue("@image", bDocBuffer);
cmPerson.Parameters.AddWithValue("@imgtype", strMimeType);
cmPerson.ExecuteNonQuery();

If in case that the user, did not browser for a picture, then, I have to use the nopho.jpg that is stored in the images/folder of my web app. How am I be able to do this?

View 1 Replies


Similar Messages:

Web Forms :: How To Allow User To Upload Picture And Then Save The Picture In Database

Feb 8, 2011

i'm new to c# and i wanted to know how can i allow user to upload a picture from a text box and a button??

after uploading the picture, how can i save the picture in the database??

**note**the picture i allow user to upload need to be in a fixed size.

View 4 Replies

C# - Put Picture From Database To PictureBox?

Dec 21, 2010

i have sql-server-2008 database that contain image field that hold picture.

i have pictureBox control in my webform.

how to put picture from database to pictureBox control ?

(I work with C# asp.net FW3.5)

can i get any sample code or program ?

View 1 Replies

Web Forms :: Get Full Picture When Try To Put Picture In Image Control?

Dec 23, 2010

I have this code to insert a picture from database into an ImageControl on my ASP.NET form:

strConnString = "server=" + Server + ";database=" + DataBase + ";UID=" + UID + ";password=" + PASS + ";";SqlConnection MyConnection = new SqlConnection(strConnString);SqlCommand MyCommand = new SqlCommand("SELECT Pic FROM MEN WHERE ID=5", MyConnection);MyConnection.Open();SqlDataReader MyReader = MyCommand.ExecuteReader();if (MyReader.Read()){ byte[] m_MyImage = (byte[])MyReader["Pic"]; Response.BinaryWrite(m_MyImage);}

And I have this ImageControl on the form:

<asp:Image Width="88" Height="100" Runat="server" ID="m_Image" NAME="m_Image" />

but when I run the code, I see the picture big on the screen and not in my ImageControl.

i also put this in the form_load:

m_Image.ImageUrl = "MyPhoneBook.aspx?m_Image";my control is: m_Imagemy control ID is: m_Imagemy namespace is MyPhoneBook

but still dont work

View 5 Replies

Web Forms :: Displaying Picture From Database?

Jan 31, 2011

I have a webform with 2 Textbox (ID & Name), 2 grouped radio button (Male-female), and a Picturebox (Photo).

I need to display/Load Details into the given controls from the ID number. I am using VS2008 SP1, C# and MS SQL.

View 2 Replies

Unable To Upload Member's Picture Into Database

Jun 20, 2010

I am uploading member's picture into my database. However, there are instances that the member will not upload its photo. In this case, I'd like to upload instead a picture that is stored in my web app's folder. How am I going to get the picture and store it in my database.

View 4 Replies

C# - How To Show Picture That Is Stored In SQL Server Database

Dec 3, 2010

I have a SQL Server 2008 database that has image field which contains a picture.

I have a gridview in my ASP.NET web program, and I need to show the picture in:

my gridview

my image control that I have in the form

Can I get any sample code ?

View 2 Replies

Web Forms :: Upload A Picture From Clipboard Into The Page/database?

Mar 16, 2011

I have a Report a Bug page added to a small site; I have a text box where a user can type a text that will be submitted to a table in my db; how do I implement the upload of a picture, let's say a screen capture? the most convenient way (for the user) would be to be able to press the Print Scrn button and then paste it to my text box ... well, I'm sure this won't work ...

View 2 Replies

DataSource Controls :: Uploading And Retrieving Picture From Database .net

May 26, 2010

I have a picture that i would like to upload to a database. I am really new to this so i am not sure what to do. I have been using the following code below to upload and retrieve the picture, looks like its uploading ok, but i cant retrieve it. The code i am using comes from this site,

http://www.dotnetcurry.com/%28X%281%29S%28e2mwozemizhla24555f41uzz%29%29/ShowArticle.aspx?ID=129&AspxAutoDetectCookieSupport=1.

Uploading Content to database

try
{
if (cmboTopic.Text == "Blu-Ray Movie")[code].....

View 4 Replies

Data Controls :: How To Display Picture Stored In Database

Mar 20, 2013

i use visual studio 2010 i have stored image into sql server in binary format  and how to retrive that image(which is in binary format) and display in image contro 

View 1 Replies

Web Forms :: Adding Picture To SQL Database Using File Upload Control?

Nov 16, 2010

I want to add picture to my SQL database using file Upload control but I don't know which attribute should I use also I don't know how to add it in the stored procedure,

View 3 Replies

Picture From SQL Database Not Displayed By Jquery Lightbox In DetailsView ImageField?

Jul 8, 2010

when i click the picture that is displayed in the detailsView ImageField, the jquery lightbox pops up, but does not show the picture. it shows a red x in the middle of the lightbox. the same thing happens with the asp:Image control shown in the code below. The picture is stored in a SQL database Image datatype. Using master pages.

[code]....

View 2 Replies

Web Forms :: Sql-server-2008 Database That Contain Image Field That Hold Picture?

Dec 21, 2010

i have sql-server-2008 database that contain image field that hold picture.

i have pictureBox control in my webform.

how to put picture from database to pictureBox control ?

(i work with C# asp.net FW3.5)

can i get any sample code or program ?

View 2 Replies

Forms Data Controls :: How To Show Picture In Grid View From Sql Server Database

Jul 27, 2010

how to show picture in grid view from sql server database

View 4 Replies

Social Networking :: Save Facebook User Profile Picture And Details To Database

May 7, 2015

I obtained the facebook profile details of an user.Now I need to store the profile details including profile picture in my local database.

View 1 Replies

Forms Data Controls :: Picture From SQL Database Not Displayed By Jquery Lightbox In DetailsView ImageField And Asp:Image?

Jul 7, 2010

when i click the picture that is displayed in the detailsView ImageField, the jquery lightbox pops up, but does not show the picture. it shows a red x in the middle of the lightbox. the same thing happens with the asp:Image control shown in the code below. The picture is stored in a SQL database Image datatype. Using master pages.

[Code]....

[Code]....

[Code]....

View 5 Replies

Web Forms :: Uploading Picture - Error "picture Could Not Be Attached"

Mar 1, 2011

I ve an application dat am working on. The section of the upload picture works perfectly on the development environment and also on a test server but the issue comes up when it was hosted life. I started geting an error dat says picture could not be attached. I ve a folder cald Passport and dis ve been working for me on befor now but i dont now the reason y its not working now.

protected void btnUpload_Click1(object sender, EventArgs e)
{
Boolean fileOK = false;
String fileExtension = string.Empty;
String path = Server.MapPath("~/Passport/");
if (fuPassport.HasFile)
{
fileExtension = System.IO.Path.GetExtension(fuPassport.FileName).ToLower();
String[] allowedExtensions = { ".gif", ".png", ".jpeg", ".jpg" };
if (allowedExtensions.Contains(fileExtension))
{
fileOK = true;
}
}
else
{
Utilities.PortalMessage = "Please attach an image file.";
return;
}
if (fileOK)
{
try
{..............................

View 3 Replies

Inserting A Record Into Database?

Oct 10, 2010

[Code]....

[Code]....

[Code]....

[Code]....

[Code]....

View 2 Replies

ADO.NET :: Inserting Time To Sql Database

Feb 9, 2011

my sql db configured with getdate()

i need insert time manually when i ll need.

created texbox and when i inputing date and time manually in right format its ok.

but i need set default date and value for textbox current date and time.

at the same time when i will need to input time manually i can be.

here is my vb code row for inserting time to sql db

cust.HaberTarih = saat.Text

how can i set text box default value to current date and time. and can change time part when i will need.

View 1 Replies

Validating Two Ddl's Before Inserting Into Database?

Feb 8, 2011

I have two ddl'a which i insert into a database inform of a grid. Now i will like to make sure the two data i am inserting is not already on the databse and if it exist i want a message to show. I dont have anything right now. I just need ideas on how to go about it.

View 9 Replies

MVC :: Inserting Radiobutton Value In To Database?

Mar 31, 2010

I have a table memberprofile which has firstname. lastname, gender and physicalstatus. I have written repository class for memberprofile like this.

public void SaveMemberProfile(MemberProfile memberProfile)
{
matrimonyDb.MemberProfiles.InsertOnSubmit(memberProfile);
matrimonyDb.SubmitChanges();
}

[Code]....

now if i click the submit button firstname, lastname, gender ARE getting inserte in to the table. only radiobutton value is not inserting it is showing null value.

View 2 Replies

Access :: Inserting Into Database In C# Class?

Apr 9, 2010

During an adaption of a book based example application, to use an access database instead of sql server - I have come up with the final issue: It will not insert into the database! I suspect it might be to do with the OrderID, I do have it set to autonumber,but I am not too sure. This is the class that does the inserts, by adding customer information to customer table, order information to order table and ordeitems information to the orderitems table. When submitting this information on the webpage, there is the custom error that an error has occurred in your order due to this code page code behind

bool success = OrderDB.WriteOrder(order);

Session["cart"] = null;

Session["order"] = null;

if (success)

[code].....

View 9 Replies

ADO.NET :: Inserting Listbox Values To Database?

Dec 7, 2010

i have problem with adding list values(radio button list box ) to the database.my code seems to be correct.but when i clicked submit i got this error message. "Invalid column name 'Age'.all the filed names shown as invalid.how to solve this problem ?

[Code]....

and i also have another problem with a table.i'm able to insert and retrieve the data.but in sql interface all the coloums are empty.where all the data being stored.why i couldnt able to view the data?

View 3 Replies

Inserting A Row In Gridview But Reflecting In Database?

Sep 28, 2010

I am having a task that, i need to insert a row in gridview but it should not effect in to database immideately. I am having a submit button in the form, whenever i click that submit button all the data in the form should be inserted into the database in their respective tables.

View 2 Replies

C# - Inserting The Dynamic Row Of Data Into The Database?

Feb 17, 2011

I have already created add/delete rows.. if i click on addRows new rows will be added and when i click DeleteRows the row will be deleted..BUT my question is when new rows are added n the entered data in new rows need to inserted into DAtabase...

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved