Uploading An Image And Saving Itz Path In Sql !!!! (plz)

Nov 1, 2006

well, i'm using vs2005 and sql server 2000.
i've got this snippet for uploading an image and creating itz thumbnail and also saving the thumbnail and the original image in a folder.
but i also want the path of the image and the thumbnail to be stored in sql 2000 database, instead of saving the images in sql.
can some one plz provide me the way.
thanx in advance.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
' Initialize variables
Dim sSavePath As String
Dim sThumbExtension As String
Dim intThumbWidth As Integer
Dim intThumbHeight As Integer
' Set constant values
sSavePath = ".Image"
sThumbExtension = "_thumb"
intThumbWidth = 160
intThumbHeight = 120
' If file field isn’t empty
If Not fileUpEx.PostedFile Is Nothing Then
' Check file size (mustn’t be 0)
Dim myFile As HttpPostedFile = fileUpEx.PostedFile
Dim nFileLen As Integer = myFile.ContentLength
If nFileLen = 0 Then
lblStatus.Text = "No file was uploaded."
Return
End If
' Check file extension (It must be .JPG)
If System.IO.Path.GetExtension(myFile.FileName).ToLower() = ".jpg" Then
' Read file into a data stream
Dim myData() As Byte = New Byte(nFileLen) {}
myFile.InputStream.Read(myData, 0, nFileLen)
' Make sure a duplicate file doesn’t exist. If it does, keep on appending an
' incremental numeric until it is unique
Dim sFilename As String = System.IO.Path.GetFileName(myFile.FileName)
Dim file_append As Integer = 0
While System.IO.File.Exists(Server.MapPath(sSavePath + sFilename))
file_append = file_append + 1
sFilename = System.IO.Path.GetFileNameWithoutExtension(myFile.FileName) + file_append.ToString() + ".jpg"
End While
' Save the stream to disk
Dim NewFile As System.IO.FileStream = New System.IO.FileStream(Server.MapPath(sSavePath + sFilename), System.IO.FileMode.Create)
NewFile.Write(myData, 0, myData.Length)
NewFile.Close()
' Check whether the file is really a JPEG by opening it
Dim myCallBack As System.Drawing.Image.GetThumbnailImageAbort = New System.Drawing.Image.GetThumbnailImageAbort(AddressOf ThumbnailCallback)
Dim myBitmap As Drawing.Bitmap
Try
myBitmap = New Drawing.Bitmap(Server.MapPath(sSavePath + sFilename))
' If jpg file is a jpeg, create a thumbnail filename that is unique.
file_append = 0
Dim sThumbFile As String = System.IO.Path.GetFileNameWithoutExtension(myFile.FileName) + sThumbExtension + ".jpg"
While System.IO.File.Exists(Server.MapPath(sSavePath + sThumbFile))
file_append = file_append + 1
sThumbFile = System.IO.Path.GetFileNameWithoutExtension(myFile.FileName) + file_append.ToString + sThumbExtension + ".jpg"
End While
' Save thumbnail and output it onto the webpage
Dim myThumbnail As System.Drawing.Image = myBitmap.GetThumbnailImage(intThumbWidth, intThumbHeight, myCallBack, IntPtr.Zero)
myThumbnail.Save(Server.MapPath(sSavePath + sThumbFile))
imgPicture.ImageUrl = sSavePath + sThumbFile
' Displaying success information
lblStatus.Text = "Image uploaded successfully!"
' Destroy objects
myThumbnail.Dispose()
myBitmap.Dispose()
Catch errArgument As ArgumentException
System.IO.File.Delete(Server.MapPath(sSavePath + sFilename))
End Try
Else
lblStatus.Text = "The file must have an extension of JPG or GIF"
Return
End If
End Sub
Public Function ThumbnailCallback() As Boolean
Return False
End Function

View 2 Replies


ADVERTISEMENT

Uploading Image To Database

Nov 4, 2006

I'm trying to upload an image to a database along with some other info. I have a form to get all the info from the user that I want to put in the database. Everything's getting into the database except for the actual image data. When I do a "select * from table" query on the database, the Image field reads "err", however I have an imagetype field in the db and it reads "image/jpeg". I have the following code to get the image into the database:

View 2 Replies View Related

Uploading Image Files

May 25, 2007

I have a directory of files that I would like to upload with some datato a table so that I can store the files in the db. I'm not trying toparse files into rows, I want to stick the actual file in the column.Is there some kind of insert script, or bulk copy that I can use?I have about 150 docs and I would rather not go through the whole app,pick the file, upload it. etc.thx,M@

View 1 Replies View Related

Problem In Saving Image ????

Mar 27, 2008

Hi
i am using textcopy to store image (named as mypic.jpg) in image column.
But i am getting error :
text or image pointer and timestamp retrieval failed

I guess this is bacause of image size ...
The default image column length is 16. I tried changing it but it's not changing and Books Online shows that the image column can store max upto 2 GB.

I just want to know also how to change that size to say 100kb?????


thanx in advance

San

View 3 Replies View Related

Saving Image To Database

Oct 24, 2006

Using: Compact Framework 1.0 and SQL Server CE 2.0

i want to save an image to my sql server ce 2.0 database on the device.
In the Compact Framework 1.0 the Image class does not have .FromStream method, and the PictureBox class does not .Save method.

Has anyone done this before in SQL CE 2.0 and CF1.0


Thanks

View 1 Replies View Related

Reporting Services :: Default Path For Saving Reports On File System?

Jun 23, 2015

during period of troubles connecting to Local Servers and Sites location i.e., to [URL], the place where all Reports are saved by default, I have continued to work on some Reports that have been saved to file system of my localhost/developing machine. But, upon recovery of http location, I can not see/open those files?

how to approach those files in order to open them in Report Builder 3.0 and thus, to "save as" them to the http location? Seems that Report Builder has chosen that location, by default, somehow.....

View 2 Replies View Related

Saving Image In SQL Server Or In Harddrive

Sep 24, 2003

I am trying to store about millions of pictures in Web server with lots of traffic. some poeple told me. SQL server cannot handle it and may freeze quickly. can anybody tell me which way is better and more efficent? store image in SQL server image field or store in server's harddrive?

View 13 Replies View Related

Saving Image To Db Using ADO. Crystal V6 Problem

Sep 11, 2006

Hi folks,

I am really hoping there is someone out there with the answer to my problems??

I need to save customer signatures to our SQL DB and then display them on a Crystal Report. The problem is that the client uses Crystal v6. I am saving the image to an Image field using an ADO rs on a VB6 application. It saves fine and will read back fine. Crystal however has a problem and throws an error "Not Supported".(Later versions of Crystal erad the images fine)

Northwind Database has a Table 'Categories' which as images that crystal v6 is able to display. As of yet I have been unable to save images in this format. I have tried .bmp,.jpg ...... I have also tried appendChunk..

All the images on Northwind start with '0x151C2...'

My bmp start with '0xFFD8....'

Any suggestions would be greatly appreciated.

View 1 Replies View Related

Scan Path Of Image

Feb 25, 2008

Hi all,
I have a scanner that dump the images into a directory. Because of thousand images dump per day, I want to moved the images into another directory each day as nightly schedule. However I like the path of the images moved stored into the database, to retrieve later. Have anyone design something like this? Right now, I get the file name from the text files, import to the database and update the path directory. I was hoping to get away from this...and do this as a jobs.

thanks

View 2 Replies View Related

Saving An Jpeg Into Database And Displaying It Into A Image Box

Oct 19, 2006

can some one help me. im using visual studio.net 2005. its a web application.i have a database with attribute name logo. so i want to upload an image and save it into the database and than display it into the image box to preview how the image looks like.can some one please help me as i am very new in using C# codes and visual studio.net 2005

View 5 Replies View Related

Replace*** In Image Path Field.

Nov 21, 2006

I am hoping someone will be able to help me with this.
i have a table of accountholders with the following fields
account_no
account_name
image_path
the image_path field has a defaultvalue images/***.jpg
I am looking for a query code to update the value in the image_path field by replacing the *** value with the value of the

account_no field

View 1 Replies View Related

VB (5or6) Does Something Wierd With Image Data While Saving To Sql2000

Apr 27, 2006

Vb stores an image (bitmap/jpg) in a SQL2000 image field. For somereason it doubles the size by adding 00 for each byte. But sometimes itdoesn't add 00 (0000.0000) but 01 or 20 or ?? and also the byte thatshould be transferd is changed...So SQLImageData = Imagebyte + 00and sometimesSQLImageData = CHANGEDImagebyte + xx.Some example data: (hex notation):A1 => A1 0003 => 03 00-----------91 => 18 2083 => 92 018C => 52 01Could anybody give me an explanation, because I need to know what ishappening, so I can remove te extra bytes added......I have already a image when I remove the extra bytes, but with somewrong data (on the place where things like 8C => 52 01 happen)....Thx,Geronimo

View 2 Replies View Related

My Dataset Is Saving Only The First Image Saved In The Database In Subsquent Rows

Mar 13, 2007

When i click upload image button when my database table has no any row, the selected image is saved(one row saved in table). If i continue and select a different image, i get no error sa if the image has been saved but when i view the images i have been saving, its strange even if i saved 10 records they all contain the first image that i saved. In short only the first image is saved the rest of the rows are just duplicates of the first row. so it basically becomes a table of ten rows but with same data rows(same image). Code is below.
Protected Sub btnupload_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim intLength As Integer
Dim arrContent As Byte()
If FileUpload.PostedFile Is Nothing Then
Lblstatus.Text = "No file specified."
Exit Sub
Else
Dim fileName As String = FileUpload.PostedFile.FileName
Dim ext As String = fileName.Substring(fileName.LastIndexOf("."))
ext = ext.ToLower
Dim imgType = FileUpload.PostedFile.ContentType
If ext = ".jpg" Then
ElseIf ext = ".bmp" Then
ElseIf ext = ".gif" Then
ElseIf ext = "jpg" Then
ElseIf ext = "bmp" Then
ElseIf ext = "gif" Then
Else
Lblstatus.Text = "Only gif, bmp, or jpg format files supported."
Exit Sub
End If
intLength = Convert.ToInt32(FileUpload.PostedFile.InputStream.Length)
ReDim arrContent(intLength)
FileUpload.PostedFile.InputStream.Read(arrContent, 0, intLength)
If Doc2SQLServer(txtTitle.Text.Trim, arrContent, intLength, imgType) = True Then
Lblstatus.Text = "Image uploaded successfully."
Else
Lblstatus.Text = "An error occured while uploading Image... Please try again."
End If
End If
End Sub
Protected Function Doc2SQLServer(ByVal title As String, ByVal Content As Byte(), ByVal Length As Integer, ByVal strType As String) As Boolean
Try
Dim cnn As Data.SqlClient.SqlConnection
Dim cmd As Data.SqlClient.SqlCommand
Dim param As Data.SqlClient.SqlParameter
Dim strSQL As String
strSQL = "Insert Into Images(imgData,imgTitle,imgType,imgLength,incident_id) Values(@content,@title,@type,@length,@incident_id)"
Dim connString As String = "Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|safetydata.mdf;Integrated Security=True;User Instance=True"
cnn = New Data.SqlClient.SqlConnection(connString)
cmd = New Data.SqlClient.SqlCommand(strSQL, cnn)
param = New Data.SqlClient.SqlParameter("@content", Data.SqlDbType.Image)
param.Value = Content
'cmd.Parameters.AddWithValue(param)
cmd.Parameters.AddWithValue("@content", Content)
 
param = New Data.SqlClient.SqlParameter("@title", Data.SqlDbType.VarChar)
param.Value = title
cmd.Parameters.Add(param)
param = New Data.SqlClient.SqlParameter("@type", Data.SqlDbType.VarChar)
param.Value = strType
cmd.Parameters.Add(param)
param = New Data.SqlClient.SqlParameter("@length", Data.SqlDbType.BigInt)
param.Value = Length
cmd.Parameters.Add(param)
cmd.Parameters.AddWithValue("@incident_id", id.Text)
cnn.Open()
cmd.ExecuteNonQuery()
cnn.Close()
Return True
Catch ex As Exception
Return False
End Try
End Function

View 1 Replies View Related

Automating A Query And The Saving Saving Of Subsequent Results

Dec 13, 2007

Hi Guys,

I am trying to automate a basic task using SQL Server 2005 Express.

Currently I have a query script that I run and then save the results as a CSV file. I need to do this on a daily basis and so I am looking to find out how best to go about this. There are a multitude of third party tools that claim to be able to do this - can anyone recommend this or enlighten me of the best way to set up this automation.

All ideas gratefully received!

View 1 Replies View Related

Subject: BCM Install Error - Logfile && SQL Path Path && MSSQL.1?

Apr 16, 2008

When trying to install Business Contact Manager (BCM) for Outlook 2007, the setup failed and I was refered to a log file in my Local Settings/Temp folder. The log actually says that Business Contact Manager was installed sucessfully! BCM is supposed to install SQL Express 2005 as an instance or as instance if SQL Express is already installed. There is an MSSMLBIZ instance in Services..

Who can I send the Log File to for analysis and the fix feedback?

When I first went into Computer Management and clicked on Services and Applications in the left panel, the error message appeared "Snap-in failed to intialize. Name: SQL Server Configuration Manager CLSID:{CA9F8727-31DF-41D2-975C-887D84903967} This message diappeared when I clicked on Services and Applications again. Under Services, there are 3 SQL services - one is an application that was uninstalled 3-4 weeks ago and I disabled this service. The other 2 are: SQL Server (MSSMLBIZ) and the other one is SQL Server (SQLEXPRESS) When I tried to start either of the last 2, the message appeared: Services "Could not start the SQL Server (MSSMLBIZ) service on Local Computer. Error 3: The system cannot find the path specified. Under Program Files/Microsoft SQL Server/MSSGL.1 folder is mostly empty. So, it seems like the Path in the Registry is not valid and that nothing is being installed in the MSSQL.1 folder. If so, how do I fix this?

How do I get the BCM SQL instance to install and run properly? what do the messages in Services mean and how do I resolve these.

Thank you!

Gary

View 3 Replies View Related

SQL Server Not Starting - Tempdb Path Updated To Wrong Path

Oct 4, 2007

After updating TempDB path to a wrong path (without file name only folder name) the service is not starting. How can i sovle this and start the service

thanks

Leena

View 13 Replies View Related

Sending Uploaded Image To Data Access Class When Storing Image In SQL Server 2005

Apr 20, 2007

I am using the 3-tiered architecture design (presentation, business laws, and data acess layers). I am stuck on how to send the image the user selects in the upload file control to the BLL and then to the DAL because the DAL does all the inserts into the database. I would like to be able to check the file type in the BLL to make sure the file being uploaded is indeed a picture. Is there a way I can send the location of the file to the BLL, check the filetype, then upload the file and have the DAL insert the image into the database? I have seen examples where people use streams to upload the file directly from their presentation layer, but I would like to keep everything seperated in the three classes if possible. I also wasn't sure what variable type the image would be in the function in the BLL that receive the image from the PL. If there are any examples or tips anyone can give me that would be appreciated.

View 2 Replies View Related

How To Save Image In Sql Server And Display That Image In Datagrid??

Jun 27, 2007

Hay Friend's
Can u plese send me the way how to save image in sql server and display that images in datagrid or other control also like Image control or Image control Button?? Plese send the coding in C#.
 Thank's
Amit

View 5 Replies View Related

How To Store Image In Image Field In Sql Server 2000

Jul 12, 2007



hi all,

i have created a table with image field in it. Now i just want to store a jpeg file in it but not finding any way to do so.



how can i store any image ? what are the steps???????





thanx in advance



View 5 Replies View Related

HOW To Retrieve An Image From Sql Server And Display It In ASP.net Using Imagemap Or Image ?

Jul 6, 2006

Ok, the problem is that , i have a field called "Attach" in sql of type image, when selecting it , the field is getting data of type BYTE(). which am being unable to display them on an Image on the panel.

using the following vb.net code:

'Dim sel2 As String

'Dim myCom As SqlCommand

'Dim conn As New SqlConnection

'Dim drr As SqlDataReader

'Dim image As System.Drawing.Image

'sel2 = "select * from attach where att_desc = '" & DropDownList1.SelectedItem().Text & "' and doc_code = " & w_doc_code & " and subcode = " & w_doc_subcode & " and doc_num= " & w_doc_num & " "

'conn.ConnectionString = ("server=developer01;uid=sa;password=aims;database=DVPSOC;timeout=45")

'myCom = New SqlCommand(sel2, conn)

'conn.Open()

'drr = myCom.ExecuteReader()

'If drr.Read Then

' Me.ImageMap1.ImageUrl = drr.Item("attach")

'End If

'conn.Close()

Am getting an exeption on the following line Me.ImageMap1.ImageUrl = drr.Item("attach")

saying: Conversion from type 'Byte()' to type 'String' is not valid.

knowing that i tried converting using ToString but it's not getting any output then.

thanks for your help.

View 4 Replies View Related

How Image Display From SqlServer To Image Control

Feb 13, 2007

I have learned lots of informative thing from your forums. I have little problem regarding “Display image from SQL Server on ASP.NET� I have done it and image display on my page from SQL Server. I have cleared you here I have adopt two different methods which are following for displaying picture.

1.Response.BinaryWrite(rd("picture"))
2.image.Save(Response.OutputStream, ImageFormat.Jpeg)

but in both above methods I have faced little problem when image display on my page all other information can not display and I also want to display picture on my specific location on the page. My second question is can use any web control like “Image1� to display image from SQL Server where my pictures are stored.

Hope you will help me.

Thanks and regards


Aftab Abbasi

View 4 Replies View Related

Inserted The Image In A Column----how Can I View The Image

Mar 7, 2006

hi,i have inserted the image present in mydocuments using alter commandcreate table aa(a int, d image)insert into aa values (1,'F:prudhviaba 002.jpg')when i doselect * from aai am getting the result in the column d as0x463A5C707275646876695C70727564687669203030322E6A 7067how i can i view the image?pls clarify my doubtsatish

View 2 Replies View Related

1st Image Control Shows Wrong Image

Jan 30, 2007

In my asp.net application I have a local report with an image control in thedetail row of the table and the Value attribute set as="File://" & Fields!FQPhotoFileName.ValueThe first row in the table always shows the wrong image and it's always thesame wrong image. The problem is there even when I change the sort order orthe criteria for the underlying dataset. For example, I ran a small testthat populated the dataset with 2 rows and 2 images. When I sort by anycolumn (e.g. ID) in ascending ascending order the ID=1 row (the 1st row)shows the wrong image and the ID=2 row shows the correct image. When I rerunthe report sorting in descending order the ID=2 row (which is now the 1strow) shows the wrong image and the ID=1 shows the correct image.Any suggestions?

View 1 Replies View Related

Image Located On Web, Url For Image Stored In Database

Aug 17, 2007



Hi,
I have a website and i am uploading the gif image to the database. i have used varchar(500) as the datatype and i am saving the file in the webserver so the path to it c:intepub....a.gif


my upload table has the folliwing feilds
UploadId Int Identity, Description, FileName, DiskPath varchar(500), weblocation varchar(500). I have a main sproc for the report where i am doing a inner join with other table to get the path of the gif..

So my question is how can i get a picture to show up on the report. .
What kinda datatype the gif file should be stored in the database? If it is stored as a varchar how can i access it and what is best way to reference that particular.

any help will appreciated....
Regards
Karen

View 9 Replies View Related

Inserting Image File Into Image Column In DB

Sep 20, 2006

I have inherited a VS 2005 database with a table that has a column of type IMAGE. I need to change the image for one of the rows in the table. I have the new image in a *.PNG file on my C: drive. What is the correct method for inserting this file into the IMAGE column.

Many thanks!

View 6 Replies View Related

Uploading Data

Sep 22, 2006

Hi There are so many records to upload into sql server DB.we have to use scripts for this?I don't know about script.How it will be usefull and how to implement ?please help me.Thanksswapprose.

View 1 Replies View Related

Uploading An Sql Database

Oct 3, 2006

hi,my sql database works fine from my desktophowever when uploading it to my web server it does not work.i considered this could be the connection path to the database.in visual web developer i attempted to modify the connection for the actual web address on the server pc like this:C:Inetpubvhostsarcvillage.comhttpdocsApp_Datavillagers.mdf this is the actual path on the server.However visual web developer will not allow this because it says that this connection is not available ON MY PC.... so i cant save this new connection in order to upload it.any suggestions please.... or am i barking up the wrong tree!

View 8 Replies View Related

Uploading CSV/XLS File

Nov 26, 2007

I want to upload csv/xls file with more than 65000 of records.But i get an error after sometime 'Timeout Expired' while uploading into database.can anyone help me how to solve this problem.its very urgent.

View 1 Replies View Related

Uploading SQL Tables

Dec 26, 2007

In my web application I am using tables with more than 100 fields. I build such tables in my PC by means of Server Explorer. If I am not wrong such tables reside in the App_Data folder. When I upload my application to my Web Host  I would like not to build hem again. Is there any procedure  to easily reuse the already built tables and to maintain them? My Web Host provides unusable instruments to rebuild long tables. To connect to them a new Connection String is required.

View 1 Replies View Related

Regarding Uploading A Database

Jan 22, 2008

i need to upload a database(mssql2000) into a remote server.i usually generate script of the source database and run that script in the sqlanalyser in the server and generate all the tables,sp,views, etc. but not diagram.
but currently i am using a diagram with relationship set between different tables in my local machine, i don't know how to upload this diagram to the remote server, if know any method pls reply.......
 
 
 
 

View 1 Replies View Related

Uploading Images To SQL DB

Nov 17, 2005

Hi,I really appreciate any help from somebody that could help me on how I can upload images in a GridView or DetailsView using ASP.NET 2.0 - VB.NETI have looked on the internet, but could not find any example....Here are my pages :ASPX-Page :
<asp:SqlDataSource ID="SqlDataSource2"
runat="server" ConnectionString="<%$ ConnectionStrings:IMMOASPNETDBConnectionString %>"
DeleteCommand="DELETE FROM aspnet_BuyGroundImages WHERE (BuyGroundID = @Original_BuyGroundID)"
InsertCommand="AddImage" SelectCommand="SELECT BuyGroundID, BuyGroundDescription, Image1, Image2, Image3, Image4, Image5, OptionOn, Sold, Price FROM aspnet_BuyGroundImages" UpdateCommand="UPDATE aspnet_BuyGroundImages SET BuyGroundDescription = @BuyGroundDescription, Image1 = @Image1, Image2 = @Image2, Image3 = @Image3, Image4 = @Image4, Image5 = @Image5, OptionOn = @OptionOn, Sold = @Sold, Price = @Price WHERE (BuyGroundID = @original_BuyGroundID)" InsertCommandType="StoredProcedure">
<DeleteParameters>
<asp:Parameter Name="Original_BuyGroundID" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="BuyGroundDescription" />
<asp:Parameter Name="Image1" Type="Byte" />
<asp:Parameter Name="Image2" Type="Byte" />
<asp:Parameter Name="Image3" Type="Byte" />
<asp:Parameter Name="Image4" Type="Byte" />
<asp:Parameter Name="Image5" Type="Byte" />
<asp:Parameter Name="OptionOn" />
<asp:Parameter Name="Sold" />
<asp:Parameter Name="Price" />
<asp:Parameter Name="original_BuyGroundID" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="BuyGroundID" Type="Int32" />
<asp:Parameter Name="BuyGroundDescription" />
<asp:Parameter Name="Image1" />
<asp:Parameter Name="Image2" />
<asp:Parameter Name="Image3" />
<asp:Parameter Name="Image4" />
<asp:Parameter Name="Image5" />
<asp:Parameter Name="OptionOn" />
<asp:Parameter Name="Sold" />
<asp:Parameter Name="Price" />
<asp:Parameter Name="LastUpdated" Type="DateTime" />
</InsertParameters>

</asp:SqlDataSource>
<asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" AutoGenerateRows="False"
DataKeyNames="BuyGroundID" DataSourceID="SqlDataSource2" Height="50px" Width="125px" BackColor="White" BorderColor="#336666" BorderStyle="Double" BorderWidth="3px" CellPadding="4" GridLines="Horizontal">
<Fields>
<asp:BoundField DataField="BuyGroundID" HeaderText="BuyGroundID" InsertVisible="False"
ReadOnly="True" SortExpression="BuyGroundID" />
<asp:BoundField DataField="BuyGroundDescription" HeaderText="BuyGroundDescription"
SortExpression="BuyGroundDescription" />
<asp:TemplateField HeaderText="Image1" SortExpression="Image1">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Image1") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:FileUpload ID="FileUpload1" runat="server" />
<!-- <input id="File1" type="file" language="javascript" runat="server" />
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Image1") %>'></asp:TextBox> -->
</EditItemTemplate>
<InsertItemTemplate>
<input id="File2" type="file" language="javascript" runat="server" />
<!-- <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Image1") %>'></asp:TextBox> -->
</InsertItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Image2" SortExpression="Image2">
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("Image2") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<input id="File3" type="file" language="javascript" runat="server" />
<!-- <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Image2") %>'></asp:TextBox> -->
</EditItemTemplate>
<InsertItemTemplate>
<input id="File4" type="file" language="javascript" runat="server" />
<!-- <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Image2") %>'></asp:TextBox> -->
</InsertItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Image3" SortExpression="Image3">
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("Image3") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<input id="File5" type="file" language="javascript" runat="server" />
<!-- <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Image3") %>'></asp:TextBox> -->
</EditItemTemplate>
<InsertItemTemplate>
<input id="File6" type="file" language="javascript" runat="server" />
<!-- <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Image3") %>'></asp:TextBox> -->
</InsertItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Image4" SortExpression="Image4">
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("Image4") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<input id="File7" type="file" language="javascript" runat="server" />
<!-- <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Image4") %>'></asp:TextBox> -->
</EditItemTemplate>
<InsertItemTemplate>
<input id="File8" type="file" language="javascript" runat="server" />
<!-- <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Image4") %>'></asp:TextBox> -->
</InsertItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Image5" SortExpression="Image5">
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("Image5") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<input id="File9" type="file" language="javascript" runat="server" />
<!-- <asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("Image5") %>'></asp:TextBox> -->
</EditItemTemplate>
<InsertItemTemplate>
<input id="File10" type="file" language="javascript" runat="server" />
<!-- <asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("Image5") %>'></asp:TextBox> -->
</InsertItemTemplate>
</asp:TemplateField>
<asp:CheckBoxField DataField="OptionOn" HeaderText="OptionOn" SortExpression="OptionOn" />
<asp:CheckBoxField DataField="Sold" HeaderText="Sold" SortExpression="Sold" />
<asp:BoundField DataField="Price" HeaderText="Price" SortExpression="Price" />
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowInsertButton="True" ButtonType="Button" />
</Fields>
<FooterStyle BackColor="White" ForeColor="#333333" />
<EditRowStyle BackColor="#339966" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="White" ForeColor="#333333" />
<PagerStyle BackColor="#336666" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#336666" Font-Bold="True" ForeColor="White" />
</asp:DetailsView>Code behind page:
Imports System.IO
Imports System.Data
Imports System.Data.SqlClient
Partial Class gronden
Inherits System.Web.UI.Page
Protected Sub DetailsView1_ItemUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewUpdateEventArgs) Handles DetailsView1.ItemUpdating
Try
'copy file data into record?
Dim upload As FileUpload = CType(Me.DetailsView1.FindControl("FileUpload1"), FileUpload)
If Not upload Is Nothing Then
If upload.PostedFile.FileName <> "" Then
'copy file to a byte array in memory
Dim data(upload.PostedFile.ContentLength) As Byte
upload.PostedFile.InputStream.Read(data, 0, upload.PostedFile.ContentLength)
'get filename part only
Dim filename As String
Dim tmp As Integer = upload.PostedFile.FileName.LastIndexOf("")
If tmp >= 0 Then
'strip directory part
filename = upload.PostedFile.FileName.Substring(tmp + 1, _
upload.PostedFile.FileName.Length - tmp - 1)
Else
filename = upload.PostedFile.FileName
End If
'save this to the fields
e.NewValues("Image1") = data
e.NewValues("FileName") = filename
e.NewValues("Contenttype") = upload.PostedFile.ContentType
End If
End If
Catch Ex As Exception
Response.Write(Ex.StackTrace)
End Try
End Sub
 
End Class

View 1 Replies View Related

Uploading A File Into The Db

Feb 27, 2006

I have yet to create a query string that works and it is beginning to drive me insane. I am trying to allow a user to upload a word document into my SQL 2000 database. However I always seem to get an error when it comes time to insert the file. The table has 5 fields memnumber, papertitle, and file type are all varchar. Length is an integer and actual_file is of type image. Here is my string 
command = "INSERT INTO resumes (memnumber, papertitle, length, filetype, actual_file) VALUES ( '" & TextBox1.Text & "', '" & rightname & "', " & length & ", '" & type & "', " & filer & ")"
I can't tell you how many different versions of this string I have tried to run with none of them working, so the errors I have gotten have been varied. Most of them tell me either I can't use the & operator with file type image or that string or binary data would be truncated.

View 6 Replies View Related

Uploading Images

Apr 11, 2001

We are building an ASP application with SQL Server 2000 as a back end.

What is the best way to upload images to the server?

Thank you,
Anastasia.

View 1 Replies View Related







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