Working With Image Data.

May 24, 2000

I have a ot of images in my hard disk and I want to put
these ina table in a column declared as an image datatype.
How do I do it?
After I am done with that, I want to select my images and should able to see the pictures.
Can any one help?
I know about the textptr function but the booksonline doesn't show mw how
to set my textptr to a specific location on my hard rive.
Any help is appreciated.
I need this because the customers do send the images of their proucts which should go into the database.

Thanks

View 1 Replies


ADVERTISEMENT

Storeing PDF's In SQL 2005 Using Image Data Type, Not Working...

Jul 20, 2007

Hi everyone, I have an odd problem.  I have a generic upload/download ASP.net page that allows the upload and download of and type of file.  I have so far tested the following file types:
XLS, MDB, JPG, DLL, EXE, PDF, TXT, SWF, and GIF
All of these upload and download fine, EXCEPT PDF's.  I have tried 4 different PDF's and all open prior to upload/download, but after uploading and downloading, I get the following (from Adobe Reader) error upon trying to open:
"There was an error opening this document.  The file is damaged and could not be repaired"
 Here's my current code:
9      Protected Sub ItemCommand_Click(ByVal sender As System.Object, ByVal e As RepeaterCommandEventArgs)10   11       If e.CommandName = "open" Then12         Dim sqlConn As New SqlConnection(ConfigurationManager.ConnectionStrings("data_partsbranding").ConnectionString)13         Dim sSQL As New StringBuilder14         Dim sqlCmd As SqlCommand15         Dim sqlReader As SqlDataReader16         Dim byteArray(UploadedFile.PostedFile.InputStream.Length) As Byte17   18         sSQL.Append(" SELECT      * ")19         sSQL.Append(" FROM        [survey_document] ")20         sSQL.Append(" WHERE       [sd_document_code] = @sd_document_code ")21   22         sqlCmd = New SqlCommand(sSQL.ToString, sqlConn)23   24         sqlCmd.Parameters.AddWithValue("@sd_document_code", e.CommandArgument)25   26         sqlConn.Open()27         sqlReader = sqlCmd.ExecuteReader28   29         While sqlReader.Read30   31           Response.ContentType = sqlReader("sd_mime_type").ToString()32           Response.BinaryWrite(sqlReader("sd_document"))33           Response.AddHeader("Content-Disposition", "attachment;filename=" & sqlReader("sd_file_name").ToString())34         End While35   36         sqlReader.Close()37         sqlConn.Close()38   39       End If40   41     End Sub42   43     Protected Sub btnInsert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInsert.Click44   45       'Make sure a file has been successfully uploaded46       If UploadedFile.HasFile Then47   48         'Connect to the database and insert a new record into Products49         Dim sqlConn As New SqlConnection(ConfigurationManager.ConnectionStrings("data_partsbranding").ConnectionString)50         Dim sSQL As New StringBuilder51         Dim sqlCmd As SqlCommand52         Dim byteArray(UploadedFile.PostedFile.InputStream.Length - 1) As Byte53   54         'Read the files binary data into a Byte array55         UploadedFile.PostedFile.InputStream.Read(byteArray, 0, byteArray.Length)56   57         sSQL.Append(" INSERT INTO [survey_document] ")58         sSQL.Append(" (           sd_document ")59         sSQL.Append(" ,           sd_title ")60         sSQL.Append(" ,           sd_file_name ")61         sSQL.Append(" ,           sd_upload_date ")62         sSQL.Append(" ,           sd_mime_type ")63         sSQL.Append(" ) VALUES (  @sd_document ")64         sSQL.Append(" ,           @sd_title ")65         sSQL.Append(" ,           @sd_file_name ")66         sSQL.Append(" ,           @sd_upload_date ")67         sSQL.Append(" ,           @sd_mime_type ")68         sSQL.Append(" ) ")69   70         sqlCmd = New SqlCommand(sSQL.ToString, sqlConn)71   72         sqlCmd.Parameters.AddWithValue("@sd_title", FileTitle.Text.Trim())73         sqlCmd.Parameters.AddWithValue("@sd_mime_type", UploadedFile.PostedFile.ContentType)74         sqlCmd.Parameters.AddWithValue("@sd_file_name", System.IO.Path.GetFileName(UploadedFile.PostedFile.FileName))75         sqlCmd.Parameters.AddWithValue("@sd_upload_date", Now)76         sqlCmd.Parameters.AddWithValue("@sd_document", byteArray)77   78         sqlConn.Open()79         sqlCmd.ExecuteNonQuery()80         sqlConn.Close()81   82       Else83   84         'Either the file upload failed or no file was selected85   86       End If87   88     End SubI have also tried the following code as a result of searching far and wide, trying other peoples methods:
 1 Protected Sub ItemCommand_Click(ByVal sender As System.Object, ByVal e As RepeaterCommandEventArgs)
2
3 If e.CommandName = "open" Then
4 Dim sqlConn As New SqlConnection(ConfigurationManager.ConnectionStrings("data_partsbranding").ConnectionString)
5 Dim sSQL As New StringBuilder
6 Dim sqlCmd As SqlCommand
7 Dim sqlReader As SqlDataReader
8 Dim byteArray(UploadedFile.PostedFile.InputStream.Length) As Byte
9
10 sSQL.Append(" SELECT * ")
11 sSQL.Append(" FROM [survey_document] ")
12 sSQL.Append(" WHERE [sd_document_code] = @sd_document_code ")
13
14 sqlCmd = New SqlCommand(sSQL.ToString, sqlConn)
15
16 sqlCmd.Parameters.AddWithValue("@sd_document_code", e.CommandArgument)
17
18 sqlConn.Open()
19 sqlReader = sqlCmd.ExecuteReader
20
21 While sqlReader.Read
22
23 Dim buffer() As Byte = sqlReader("sd_document")
24 Dim blen As Integer = CType(sqlReader("sd_document"), Byte()).Length
25
26 Response.ContentType = sqlReader("sd_mime_type").ToString()
27 Response.OutputStream.Write(buffer, 0, blen,)
28 Response.AddHeader("Content-Disposition", "attachment;filename=" & sqlReader("sd_file_name").ToString())
29 End While
30
31 sqlReader.Close()
32 sqlConn.Close()
33
34 End If
35
36 End Sub
37
38 Protected Sub btnInsert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInsert.Click
39
40 'Make sure a file has been successfully uploaded
41 If UploadedFile.HasFile Then
42
43 'Connect to the database and insert a new record into Products
44 Dim sqlConn As New SqlConnection(ConfigurationManager.ConnectionStrings("data_partsbranding").ConnectionString)
45 Dim sSQL As New StringBuilder
46 Dim sqlCmd As SqlCommand
47 Dim byteArray(UploadedFile.PostedFile.InputStream.Length - 1) As Byte
48
49 'Read the files binary data into a Byte array
50 UploadedFile.PostedFile.InputStream.Read(byteArray, 0, byteArray.Length)
51
52 sSQL.Append(" INSERT INTO [survey_document] ")
53 sSQL.Append(" ( sd_document ")
54 sSQL.Append(" , sd_title ")
55 sSQL.Append(" , sd_file_name ")
56 sSQL.Append(" , sd_upload_date ")
57 sSQL.Append(" , sd_mime_type ")
58 sSQL.Append(" ) VALUES ( @sd_document ")
59 sSQL.Append(" , @sd_title ")
60 sSQL.Append(" , @sd_file_name ")
61 sSQL.Append(" , @sd_upload_date ")
62 sSQL.Append(" , @sd_mime_type ")
63 sSQL.Append(" ) ")
64
65 sqlCmd = New SqlCommand(sSQL.ToString, sqlConn)
66
67 'sqlCmd.Parameters.AddWithValue("@sd_title", PictureTitle.Text.Trim())
68 'sqlCmd.Parameters.AddWithValue("@sd_mime_type", UploadedFile.PostedFile.ContentType)
69 'sqlCmd.Parameters.AddWithValue("@sd_file_name", System.IO.Path.GetFileName(UploadedFile.PostedFile.FileName))
70 'sqlCmd.Parameters.AddWithValue("@sd_upload_date", Now)
71 'sqlCmd.Parameters.AddWithValue("@sd_document", byteArray)
72
73 sqlCmd.Parameters.Add(New SqlParameter("@sd_mime_type", SqlDbType.VarChar))
74 sqlCmd.Parameters.Add(New SqlParameter("@sd_title", SqlDbType.VarChar))
75 sqlCmd.Parameters.Add(New SqlParameter("@sd_upload_date", SqlDbType.DateTime))
76
77 sqlCmd.Parameters.Add(New SqlParameter("@sd_file_name", SqlDbType.VarChar))
78
79 sqlCmd.Parameters.Add(New SqlParameter("@sd_document", SqlDbType.Image))
80
81 Dim bArray(UploadedFile.PostedFile.ContentLength - 1) As Byte
82
83
84
85
86
87
88 UploadedFile.PostedFile.InputStream.Read(bArray, 0, UploadedFile.PostedFile.ContentLength)
89
90 sqlCmd.Parameters("@sd_mime_type").Value = UploadedFile.PostedFile.ContentType
91 sqlCmd.Parameters("@sd_title").Value = PictureTitle.Text.Trim()
92 sqlCmd.Parameters("@sd_upload_date").Value = Now
93
94 sqlCmd.Parameters("@sd_file_name").Value = System.IO.Path.GetFileName(UploadedFile.PostedFile.FileName).ToLower
95
96 sqlCmd.Parameters("@sd_document").Value = bArray
97
98
99 sqlConn.Open()
100 sqlCmd.ExecuteNonQuery()
101 sqlConn.Close()
102
103 Else
104
105 'Either the file upload failed or no file was selected
106
107 End If
108
109 End Sub
110

 This method atleast gives a different error:
 "Adobe Reader could not open '132-171510.pdf' because it is either not a supported file type or the file has been damaged (for examplc, it was sent as an email attachment and wasn't correctly decoded)."
 Please help, it would be appreciated.  Thanks
 

View 5 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 Convert To Regular Text, Data Stored In Image Data Type Field ????

Jul 20, 2005

Hi,This is driving me nuts, I have a table that stores notes regarding anoperation in an IMAGE data type field in MS SQL Server 2000.I can read and write no problem using Access using the StrConv function andI can Update the field correctly in T-SQL using:DECLARE @ptrval varbinary(16)SELECT @ptrval = TEXTPTR(BITS_data)FROM mytable_BINARY WHERE ID = 'RB215'WRITETEXT OPERATION_BINARY.BITS @ptrval 'My notes for this operation'However, I just can not seem to be able to convert back to text theinformation once it is stored using T-SQL.My selects keep returning bin data.How to do this! Thanks for your help.SD

View 1 Replies View Related

Move Text Data (not A File) Into An Image Data Type

Mar 11, 2008



The ERP manufacturer used an image data type to store large text data fields. I am trying to move these data types from one database to another database using either Sql Queries or MS Access. I can cast them as an 8000 char varchar to read them directly but have no luck importing into these image data fields.

Access and Crystal are not able to read these fields directly.

Any suggestions? Most information about these fields has to do with loading files but I am just moving data.

Thanks,

Ray

View 1 Replies View Related

Ms Sql Image Data From My-sql

Jun 19, 2007

hi people



I have imported "blob" data from mysql to an ms-sql 2000 "Image" field, using ms- sql enterprise manager. However my c# image veiwer does not work on the imported blob data (it does work on data I add to ms-sql via my web application).



Is there any way I can check that the blob data creates a valid image? If anyone has any ideas of how I can debug the data coming out that would be great. Or perhaps someone can point me to somewhere I can get some help?



any pointers are much appreciated!



Greg




View 6 Replies View Related

Image Data Type

Aug 9, 2006

I have been asked to write a piece of code that will insert an image object into a database using a stored procedure and the Microsoft Enterprise Library.  Has anyone done this before?  Do you have any code examples about how to update a database with an image datatype that needs to be chunked, etc...
 
In this instance, I need to open up a word document and save the contents as an image in a database.   

View 5 Replies View Related

Image Data Type

Sep 29, 2006

hi, i'm a student doing my final year project. during the user requirements stage, my client proposed storing all files (.doc, .jpg, .mp3) into the sql database. i found out that the way to do this is to write the files as binary data in order to store them in the database. my concern is will this data storage overload the database server? i read somewhere that the retrieval of data as binary data is the same as retrieving text. but the estimation of users is around 27,000.. if i'm not wrong, the sql database server should be MS SQL Server 2005, or at least 2003.

View 1 Replies View Related

Image Data Type

Mar 10, 2008

I have a field in my personal table that has image data type as Pic,my SQL code is :
SELECT Department.ID,Department.[Name],Department.CreatedDate,Department.[Pic] ,COUNT([Group].[Name])
FROM Department INNER JOIN [Group] ON Department.ID=[Group].DepartmentID
Group by Department.ID,Department.[Name],Department.CreatedDate,Department.[Pic]
This error occured :
Msg 306, Level 16, State 2, Line 1
The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.
Please help me.
Thanks.

View 3 Replies View Related

Image Data Type

Mar 10, 2008

What save inside image data type field?
Thanks,mohsen

View 1 Replies View Related

Image Data Type

Jul 16, 2001

Hi,
I have a table with a column having image data type in it.I need to move four records from this table to another table in development box.Can any one suggest me how can i do this? I don't think insert into select * will insert image data type.Is there any way around?
thanks
Mohan

View 2 Replies View Related

Image Data Type

Jan 6, 2003

I'm developing a website with SQL SERVER 2000 and IIS6 (beta).
I'm using ASP.NET webforms for my application.
I was wondering if anyone knows how to use the Image datatype for dynamically loading images/word docs/sound files

View 5 Replies View Related

Image Data Type

Jul 1, 2002

Can anyone provide info on how to insert and store a .jpeg in a database table?
Thanks,
Kellie

View 1 Replies View Related

Image Data Problem

Jul 15, 2002

Hi,

I have a large table at a client site, about 4000 rows so that is fine but the problem is one of the columns are of image type and this has a lot of data in the table size is about 2.8 gig.
Whoever installed the server was up to no good - everything (logs, system and data files)is running on one disk which is mirrored (??? don't ask).

Indexes are on the right columns, and the server is a dual pentuim 3 700 with 2 gig of Ram so that is fine too.

The database is a CRM database (Maximizer) and when the application loads up it reads the entire table into its library (don't know why or how exactly yet) and as you can imagine this takes a long time about 4 minutes - which is too long.

My idea is to add two or more disks and get the logs on one of them then take the table with the image data and move it to one of the disks with the rest of the tables on the other disk - (The client can't afford or don't want to pay for a RAID system before you ask)

Can anyone shed some light on this whether it will do or do I rather need to go for a partitioned view over the disks.

What is the limits on TEXT IN ROW table option - will it be of any help?

Buying another server is unfortunatly not an option and archiving the older data also wont solve the problem as they do a lot of reports of the database.

Any suggestions or advice would very much be appreciated.

Regards

Jacques

View 2 Replies View Related

Image Data - Where Should It Be Stored

Feb 18, 2004

Been pondering the idea of putting 43 - 56K Pdf documents into a SQL DB but everything I've read only goes as far as to explain how the data is stored or manipulated.

I need to establish whether there are real performance issues or gains that will be experienced by doing this.

If indeed, performance would be a big issue, would storing the files in a Folder on another drive outside the Database be all that much faster (Let windows handle the fetch and carry instead of SQL Server).

The plan at the moment is to store all the image data in a separate data file or multiple data files. Using partitioned views is also a consideration.

Number of records per day (pdf's) would be somewhere around a 1000.

View 14 Replies View Related

Test Image Data

Feb 28, 2007

Hi I have the following table and just wondered if theres an easy way of inserting test data with the image field not null?

Table: file
Fields: file_id(int), filename(varchar), data(image).

Any help would be great!
Cheers, Mark

View 6 Replies View Related

Image Data Type

Aug 16, 2007

pls. Help!
I am not getting that how to use the image datatype in sql server 2000
when i am inserting text to it and on retrieving it is showing hexadecimal string ...
I want to know all of your views on the usage of image datatype..
Thanks...

View 5 Replies View Related

Image Data From MSSQL 6.5

Jan 20, 2008

I would like to use bcp and transfer image data from MS-SQL Server 6.5 to MS SQL Server 2005.

1. Can I use bcp successfully? if so should I mention any option to copy the BLOB?
2. Is there any reliable method to move tables with BLOBs

Regards,

/ash

View 7 Replies View Related

Image Data Type

Oct 5, 2005

Hi,In my SQL Server 2000, I have a Table MyUser which has one colum PassWord,and the PassWord's datatype is Image. I'm wondering how can a password bean image.Thanks for help.Jason

View 1 Replies View Related

SQL Server Image Data

Jul 20, 2005

Hi! Guys,May be this question is little stupid but I want to clarify this.Let suppose I have image data field in Sql server 2000 and I am uploadingan image of 10KB(thru asp.net application).What would be the size for that table with image data field ?Is it 10KB or less than 10KB or more than 10KB ?ThanksJohnwww.e-classifiedad.com

View 2 Replies View Related

Having Trouble Following Tutorial - Working With Data In ASP.NET 2.0 :: Creating A Data Access Layer

Nov 1, 2006

HiI'm having problems following the tutorial on creating a data access layer -  http://www.asp.net/learn/dataaccess/tutorial01cs.aspx?tabid=63 - when I try to compile in Visual Studio 2005 I get namespace could not be found. I followed exactly the tutorial - I created a dataset and added this code in my aspx page.  <asp:GridView ID="GridView1" runat="server"             CssClass="DataWebControlStyle">               <HeaderStyle CssClass="HeaderStyle" />               <AlternatingRowStyle CssClass="AlternatingRowStyle" />In my C# file I added these lines...    using NorthwindTableAdapters; <<<<<this is the problem - where does this come from?   protected void Page_Load(object sender, EventArgs e)    {        ProductsTableAdapter productsAdapter = new         ProductsTableAdapter();        GridView1.DataSource = productsAdapter.GetProducts();        GridView1.DataBind();    }Thanks in advance

View 6 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

Read Image Data From SQL Server

Sep 19, 2007

Here is my task  I am storing pdf's in sql server. I would like to retrieve the binary data from sql server and write the pdf content into an existing aspx page to the appropriate pageview section.  What is the best way to handle this.  The code works below but it loads a new browser with the content.  I need it to appear in it's tabbed section in the original aspx file.  Any assistance you can give me would be greatly appreciated.
 Thanks Jerry
oSQLConn.Open()Dim myreader As SqlDataReader
myreader = myCommand.ExecuteReader
Response.Expires = 0
Response.Buffer = True
Response.Clear()
Do While (myreader.Read())
Response.ContentType = ("application/pdf")Response.BinaryWrite(myreader.Item("img_content"))
Loop

View 5 Replies View Related

Deafult Data For Image Field

Apr 19, 2004

Hi,

I am storing my upoaded images in sql server. However, if the user does not upload an image, a broken link is shown in the page.
All that shows up in the DB field is <Binary>.

Can we set this field to a default value?
Is it possible to view this binary data.

I would like a default blank gif to be returned if no image is uploaded.

Regards,
JB

View 3 Replies View Related

OPENXML And Binary/Image Data

Aug 17, 2005

I seem to be getting very annoying behaviour from SQL Server and was wondering what the correct method should be...I want to store some binary data in the database and I want to use a stored procedure.  I also want to pass some XML to the stored procedure where this XML contains the binary data. I will then use OPENXML to grab the binary data and stick in the table. In order to ensure the safe transmission of the binary through XML I Base64 encode it. Ok so far. The problem is that although OPENXML is supposed to assume that anything marked as Image/Binary will be Base64 encoded it then proceeds to Base64 encode it again and put that result into the database! So what am I missing, am I supposed use a CDATA section or something rather than Base64 encode my XML?

View 2 Replies View Related

Store Image Data Type

May 2, 2006

Hi
when  I store html file with image in image data type of database sqlserver, where will actual data store (content of html file, and file image which display on html file), in which folder
Can I help you
 
 

View 4 Replies View Related

REplication Of Image Data (urgent)

May 3, 2002

Hello everyone,

I'm running merge replication with several databases. So far everything worked fine, but now I tried to insert some new records and I get the message:

Server: Msg 7139, Level 16, State 1, Line 1
Length of text, ntext, or image data (73728) to be replicated exceeds configured maximum 65536.
The statement has been terminated.

Can anybody tell me how if I can change this max. value and how ?
Thanks a lot
Mike B.

View 2 Replies View Related

How Can I Read From Image Data Type

May 11, 2001

I want to store my MS-Word documents and Excel sheets in the database. So, i have used
the image datatype. Iam not able to download the documents from the database.
i have used getBytes() method. But when i try to download excel sheet document, i get
a error message saying, "File error: data may have been lost".
Can i get some help. can u say how can i put word and excel docs in the database and
retrieve it.
regards,
sathish

View 2 Replies View Related

To Retrieve Image Data From A Table

Jul 25, 2001

Hi,
Can any one help me to retrieve an image data from a table.
I wanted to show the images on my web page using ASP.
I am trying with pub_info table of pubs database, in this table logo is a image data type colum. I opened a record set in ASP page and I am not able to retrieve the image from the record set.

Any help is appreciated!

Ravi.

View 2 Replies View Related

Operating On The Image Data Type

May 1, 2000

How to insert or retrieve images type data in sql server?I want to put a jpeg file in sql server.How can I accomplish that?>How to input into the table and how to retrieve that from the table
I have a table contacts.The fields are
ID int
Name Varchar
Photo Image

Can anyone help me with this?

View 1 Replies View Related

Image Data Type Size

Oct 5, 2005

I need to store images in MS SQL. I have the upload procedures and stuff but I'm missing the point about the image data type size.

It is supposed to be able to store up to 2Gb!!! but when I declare the data field image I can't specify the max size for the field and by default is 16 !!

16 bytes!! what can I do with that?
How can I insert a file?

Please help

View 2 Replies View Related







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