Insert Uploaded Images Into A Database?

Feb 11, 2011

I want to insert uploaded image in root directory images folder and its path to image column in database.

I am using the following code. It inserts the path to images in the database column, but not the filename:

Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
On Error Resume Next
If FileUpload1.HasFile Then
FileUpload1.SaveAs(IO.Path.Combine(Server.MapPath("images"), FileUpload1.FileName))
End If
'/// upload images
Dim con As New SqlConnection
Dim cmd As New SqlCommand
con.ConnectionString = "Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|Database.mdf;Integrated Security=True;User Instance=True"
con.Open()
cmd.Connection = con
cmd.CommandText = "INSERT INTO Table3 (city, hotel, location, avialiability, room, price, image, category, from1, to1, price1, from2, to2, price2, from3, to3, price3, details) VALUES('" & Trim(DropDownList1.SelectedItem.Text) & "','" & Trim(DropDownList2.SelectedItem.Text) & "','" & Trim(TextBox5.Text) & "','" & Trim(TextBox6.Text) & "','" & Trim(DropDownList3.SelectedItem.Text) & "','" & Trim(TextBox7.Text) & "','" & "images/" & FileUpload1.FileName & "','" & Trim(TextBox17.Text) & "','" & Trim(TextBox8.Text) & "','" & Trim(TextBox9.Text) & "','" & Trim(TextBox10.Text) & "','" & Trim(TextBox11.Text) & "','" & Trim(TextBox12.Text) & "','" & Trim(TextBox13.Text) & "','" & Trim(TextBox14.Text) & "','" & Trim(TextBox15.Text) & "','" & Trim(TextBox16.Text) & "','" & (Editor1.Content) & "')"
cmd.ExecuteNonQuery()
con.Close()
End Sub

View 2 Replies


Similar Messages:

AJAX :: Insert Multiple Images To Database Using FileUpload Control?

May 7, 2015

i am try this code for multipul image upload in database 

but only one image store in database  at a time 

protected void Button1_Click(object sender, EventArgs e)
{
if (file.HasFile == false)

[Code].....

View 1 Replies

Social Networking :: Save (Insert) Images From Facebook Albums To Database?

May 7, 2015

I am fetching all image from facebook and display in repeter like this 

<asp:Repeater ID="rptFaceBookAlbums" runat="server">
<ItemTemplate>
<div class="header1"><%# Eval("Name") %></div>

[Code].....

now i wnat to save all this image in database. so tell me what would be data table column structure in sql data shold be retrive to me is album wise

View 1 Replies

Forms Data Controls :: Image + Tagging + Repeator - Insert And Select Images From Database

Mar 30, 2010

I am unsure on how to perform this task, what i need to do is make a gallery with tagging. I need this as it is a requirement for the project. Each user will have there own gallery and be able to upload and delete images from there gallery. I already know how to insert and select images from a database. I will then display the gallery using a data repeator with paging, I am sure i can google an article for data repeator with paging.

My challenge is, when the user wants to save a image to there gallery, he must 1st upload the image and then i must some how display the image, when the image is displayed, i will have a text box where they can add tags, this textbox will save in the tag table for that user_id, picture_id and the tag will have an id also. I am unsure on how to do this When he clicks save, i wanna insert the image into the table, and the tag. If he does not click save, then nothing should be saved. Now the 2nd part.

In the data repeator, i want a modal window to popup when they click an image, this modal will have the image and the respective tags that where saved for this image, I am unsure how to this.

View 3 Replies

Create Thumbnails Of Uploaded Images

Apr 11, 2010

I have ran into an issue where I have to use ASP.NET to do a Thumbnail of images uploaded since the hosting company does not have any of the required ASP Classic 3rd party utilities that I can use. I have played around with several different Upload scripts before I found a tutorial on using: Uploadify (Love this script) with ASP.NET. [URL] What I am needing to do with the script is to create Thumbnails of the images that are uploaded, and when I try to do so, I get an IO Error. I was informed that I would have to create a Web Application instead of the Web Site as the web application would give me the default.aspx.designer.cs file for setting the FileUpload control as Public to be used in the upload.ashx file. But after doing that it basically breaks the code. What works in the Web Site, does not seem to want to work in the Web Application. What I would like from the .NET community is some help in making the Uploadify script to create Thumbnails. The script for the Thumbnails that I am using (or trying to use) is here

[Code]....

View 4 Replies

MVC :: Create Thumbnails For Images Uploaded?

Jan 8, 2010

- In have a website where users can upload their photo and along with their profile.- I store the photo as binary data in database.- Using ASP.NET MVC 2.0 FileContent option, I display Photo back in the browser, when user view his/her profile detailsQuestion: Currently I am showing image as-is and not restricting width/height, so that users see exactly whatever image they uploaded as-is without distortion. However I want to do like every other website: Show only smaller image alwayswith fixed size and allow user to click on it to pop-up and show original image as-is in pop-up.NOTE: I can do this simply restricting width and height to fixed limits but still show original image. But in this case image is distorted as it was not originally designed for this dimension.This very basic question and I am seeing many options, including some libraries. But don't know what is best way to do this using ASP.NET MVC 2.0

View 1 Replies

Web Forms :: Delete Uploaded Images From A Folder?

Jan 15, 2010

I'm with C# ASP.net , Please help me ... how to delete folder images in an application.

View 5 Replies

In Which Folder Can Store User Uploaded Images

Feb 10, 2011

I've a classified ads system on ASP.NET/c#/MS SQL, and I'm trying to figure out where to store the images that people upload when placing an ad. The ad itself is being stored in a SQL server database.

The images are now being stored in a subfolder of my webapp. It seems to work fine, however I only recently discovered a big problem. Everytime a user deletes an ad, the attached images are to be deleted as well including the folder they reside in. This leads to a restart of the asp.net application. I searched internet and found that restarting the web-app is actually intended behaviour when a subfolder is being deleted.

I can remove these images including the folders they are stored in?

I can acces them using a URL (the images need to be shown in the webpages) Without getting the web-app being restarted?

View 3 Replies

Web Forms :: Add Copyright Watermark Text To Uploaded Images?

Sep 19, 2012

 Is there a way to upload image and save to folder with watermark of Copyright on image ?

View 1 Replies

Restrict Access / View Images Of Other User Uploaded Using CK Editor?

Jul 17, 2010

I am using CK Editor, in my application every user have his separate email templates. I want to store images to user specific and user should not view other user uploaded images when browse to Server to upload images

View 1 Replies

Web Forms :: Images Are Not Uploaded Correctly To Server Path Of The Application Folder?

Dec 24, 2010

I have a task to upload multiple images to server path of the application folder . I have used the File Upload control in order to Upload the Images to server path but some images of about 778 kb are not supposed to be uploaded correctly. And while displaying the Images I am using Datalist control.

While I have tried to upload from Application in my system all files got uploaded but while acessing the link some files are not getting uploaded.

View 1 Replies

Data File Uploaded But Bulk Insert Isn't Working

Jun 28, 2010

I have the following code:

[code]....

What's happening is when I try to upload a file, it tells me that everything is fine but when I look in my database, there is no data there. What am I missing? This worked before but we had to move this to another directory on the server and after we did that, the bulk insert function seems to be broken, though the server isn't returning any kinds of errors.

View 1 Replies

Web Forms :: Retrieving Images From Database And Display As Thumbnail Images

Apr 29, 2010

[Code]....

i am using asp.net with c#, i have table images

shop nvarchar(50),
imgc image
imgo image

iam saving images in a database but while retreving it is showing blank images. i want to display as thumb nail images

View 1 Replies

Web Forms :: Check Whether File Is Uploaded Or Not - Upload Only Images Instead Of "All Files"

Aug 19, 2010

i have simple code. in which i want to check whether file is uploaded or not. but HasFile return false. I think every thing is ok but not working. how i will upload only images instead of "All Files"

[Code]....

View 4 Replies

C# - How To Save Uploaded Pics In Database

Sep 27, 2010

in my new c#.net 3.5 ASP Website, user have the possibility to upload a picture.What solution is the best for saving this picture? Should I save it on my server in a folder and save the path in the database, or should I save the picture in the database?

View 3 Replies

Display Uploaded Document From Database

Oct 10, 2010

I have a MVC 2 web application. The website captures grant applications for loans. With each application I can upload documents. The way that we upload documents to the database is as follows:

private IEnumerable<byte> GetStreamByteArrayData(Stream stream)
{
byte[] buffer = new byte[8192];
int bytesRead = 0;
while ((bytesRead = stream.Read(buffer, 0, buffer.Length)) > 0)
{
for (int byteIndex = 0; byteIndex < bytesRead; byteIndex++)
{
yield return buffer[byteIndex];
}
}
}

The calling method looks like this:

Convert.ToBase64String(GetStreamByteArrayData(hpf.InputStream).ToArray());

In my grid that displays the uploaded documents I have the document name, mime type and so forth. What I am trying to do is to have the name of the document in a link. When the link is clicked then the document is opened. I have no idea how to do this in an MVC app. Can someone provide some sample source code?

View 2 Replies

Web Forms :: How To Save Name Of Uploaded File In Database

May 7, 2015

I have 1 fileupload control that I can upload file from it below is code :

int count = 0;
if (this.fuppdf.HasFile && !string.IsNullOrEmpty(this.txtarticle.Text))
{
string[] validext = { ".pdf" };
//string ext = System.IO.Path.GetExtension(fuppdf.PostedFile.FileName);
string ext = Path.GetExtension(fuppdf.PostedFile.FileName);

[code].....

and with below code I want save filename (uploaded filename) in database

SqlCommand _cmd = new SqlCommand("Fileuppdf", _cn);
_cmd.CommandType = CommandType.StoredProcedure;
string data = Session["behcode"].ToString();
_cn.Open();
_cmd.Parameters.AddWithValue("@pdf", filename);
_cmd.Parameters.AddWithValue("@Behcode", data);
_cmd.Parameters.AddWithValue("@id", Convert.ToInt32(ViewState["Id"]));

but it make error in this line

_cmd.Parameters.AddWithValue("@pdf", filename);

error===>("The name 'filename' doesn't exist in the current context")

I know that I define filename in 

foreach (string s in files)but I don't know how I can save it name in database

View 1 Replies

Web Forms :: Saving Uploaded Image To Database

Feb 21, 2012

I am trying to make a photo gallery. I want to save the uploaded image to data base ...the article below at "
Display image after upload without page refresh or postback using ASP.Net AsyncFileUpload Control" shows how to show the uploaded image.. How to save the image in SQl Database?

I do not know how to do it.. Can the code be modified..? 

View 1 Replies

DataSource Controls :: Remove Uploaded Document From Database?

Jan 30, 2010

I have a Document name column with varbinary(max) type column in my table

first time when i upload document i am storing doc as a byte array

Dim fs As Stream = Me.fileupload1.PostedFile.InputStream
Dim br As New BinaryReader(fs)
Dim bytes As Byte() = br.ReadBytes(fs.Length)

in my application i have remove atttachmentDoc button, i want to remove uploaded doc from db

so when i pass like this to my storedprocedue

Dim obj As New cls1
Dim bData() As Byte = New Byte(0) {}
bData=nothing
With obj
Dim dt As DataTable = Read_Doc()
If dt.Rows.Count > 0 Then
If Not IsDBNull(dt.Rows(0)("Document")) Then
.Document = bData
.Document_extension = ""
.Remove_Attachment(Me.Selected_ID)
End If
End If
End With

i got error

dbAccess.executeQuery: Procedure or function 'SP_DML1' expects parameter '@Document', which was not supplied.

View 1 Replies

SQL Server :: Bulk Insert Or Insert Multiple Rows Into Database At A Time?

Aug 20, 2010

i need to insert multiple rows at a time into database table(sqlserver) from datatable or gridview. Actually iam looping through the rows of gridview and inserting each row. Is there any method to insert entire table of rows at a time into database table. Both datatable columns and database table coulmns are similar.

View 2 Replies

Forms Data Controls :: Insert New Blank Rows In A Gridview And Insert Them In Database Multiple At A Time?

Oct 19, 2010

I have grid view in ASP.Net 3.5. I need to add multiple blank rows in a gridview and then have to save them in database. How can I do that in most simplest way?

View 7 Replies

DataSource Controls :: Save Uploaded File Path In Database

Apr 26, 2010

how can we save the uploaded file path in to database and then retrieve it in gridview as a link so when user click on that it will open that file in browser.

View 8 Replies

C# - Sync Database To Uploaded File Using Windows Service Or Website Code?

Sep 10, 2010

I have a website that occasionally needs to have a handful of the tables in its database updated. The updates come from another system that exports to comma delimited text files. I can then either FTP the text files to the web server, send them in through an admin upload page, or manually log in to Remote Desktop to download the text files. I have all my C# code written to parse the files, check the database contents, and decide what to do.

Should I code the sync logic to be part of a file upload page, protected in the admin section of the site or should I create a Windows Service that constantly looks for files to process in a particular directory that I can drop files in through FTP?

I have used Windows Services in the past and they have worked great, but if I ever have to make a change to the code it can take longer than it would if I just had to modify an ASPX.

Are their security benefits one way or another?

Performance benefits?

ASPX page wins the "ease of maintenance" category.

View 1 Replies

Forms Data Controls :: Storing Uploaded File Content Into Database?

Dec 15, 2010

I am working on the application that allows user to upload a file (from their local machine) and store the uploaded file in database.Then,the content of the file (such as ContentType,FileSize etc)can be view in a DetailsView control.

View 1 Replies

DataSource Controls :: Insert Images Into SQL Table?

May 15, 2010

I want to insert a bunch of images into a SQL table I made.

Not sure how to get the data into a Image data Type. It's not like typing in a date or text.

Can is be done manually or must it use an insert statement?

If insert how is best done?

simple Table
ImageData Image
ImageID Int
ImageName nvarchar
ImageDescription nvarchar

Thay are all in the same folder

View 5 Replies







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