Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    MS SQL Server


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Store Multi-Select Values In An Image Data Type?


I was working on figuring out where a certain application was
storing the multiple selection choices I was doing through the app.
I finally figured out that they were being store in an IMAGE
data type colum with the variable length of 26 bytes.

This is the first time I ran into such way of storing multiple
selections in a single Image data type.

Is this a better alternative than to store into a One-to-Many
tables? If so then I'll have to consider using the Image data
type approach next time I have to do something like storing
1 to thousands of selections.

Thank you




View Complete Forum Thread with Replies

Related Forum Messages:
Store Image Data Type
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 Replies !
Converting Bytes [] To An SQL CE 3 Image Type To Store
Hi,

I was wondering if anyone knows how to convert an array of bytes to an SQL CE 3 image type and vice versa.

I am using the SDF Signature control and I would like to store the signature as an Image. It needs to be an image so it can be synced with a desktop access 2003 database.

Cheers

Simon

View Replies !
Multi Select Type-in Parameter
Hi All

Can anyone tell me whether or not it is
possible to multi select when you have a parameter
that is set as non-querried in order for it to be
typed instead of selected.

My users prefer typing the values and selecting
more than one. But at the moment I cant give them both..

I'm using SSRS with SSAS cube all in BI all 2005

Please help. I suspect that if it's possible it may just be a
syntax thing but I am yet to find it.

Thanks in advance

Gerhard Davids

View Replies !
Select Values From Multi-value Parameter
Is it possible to pass values from UI to a multi-value parameter in a report and from this report, select values from this multi-value parameter to finally display data?

Thanks!

View Replies !
Type-ahead In Multi-select Parameter Lists?
When running reports in preview mode in Visual Studio I can use type-ahead to get to selections in a dropdown multiple select parameter list by typing the first letter; typing w for instance will go to the first word in the list starting with 'w' and will automatically check it. Very useful if the lists are long enough to require scrolling. When the report is deployed to the Report Server Web page the type-ahead feature disappears. Is this because the dropdown is presented as HTML? Is there any way to get the type-ahead feature short of using a Report Viewer within a .NET application. I prefer the simplicity of the Web deployment rather than creating a VB or C# application just to show the report.  I noticed that, for single-select parameters, the type-ahead still works; I'm guessing that is because they don't have the checkboxes in front of the words. Thanks for any help.

View Replies !
Uploading An Image And Using An ASP.NET 2.0 Data Source Control Code To Store The Binary Data PROBLEM
I want to use a Stored Procedure (and add Parameters) instead of ADO.NET Code from the following article, but I'm not seeing something; could someone help me out?
Note: It's Visual Basic 2005 code, and that's what I want to use.
 http://aspnet.4guysfromrolla.com/articles/120606-1.aspx And code for article: http://aspnet.4guysfromrolla.com/code/BLOBsInDB.zip
If you look at this article, under the section: Uploading an Image and Using an ASP.NET 2.0 Data Source Control Code to Store the Binary DataIt has the following Code for the DetailsView UploadPictureUI_ItemInserting:
<asp:SqlDataSource ID="UploadPictureDataSource" runat="server"       ConnectionString="..."      InsertCommand="INSERT INTO [Pictures] ([Title], [MIMEType], [ImageData]) VALUES (@Title, @MIMEType, @ImageData)">  <InsertParameters>    <asp:Parameter Name="Title" Type="String" />    <asp:Parameter Name="MIMEType" Type="String" />    <asp:Parameter Name="ImageData" />  </InsertParameters></asp:SqlDataSource>
I tried to use the following, but It's not correct:
<asp:SqlDataSource ID="UploadPictureDataSource" runat="server"       ConnectionString="..."      InsertCommand="InsertPicture" InsertCommandType="StoredProcedure">  <InsertParameters>    <asp:Parameter Name="Title" Type="String" />    <asp:Parameter Name="MIMEType" Type="String" />    <asp:Parameter Name="ImageData" />  </InsertParameters></asp:SqlDataSource>
How do I simply replace the INSERT INTO Statement with a StoredProcedure, and set the parameters? Currently I have the Insert working, but the image shows up as an image placeholder and that's it.
ps: The stored procedure I use is below, and you might want to download the VB Code at the bottom of the article.ALTER PROCEDURE dbo.InsertPicture
 
(@PictureID int,
@Title varchar (50),@MIMEType varchar(50),
@ImageData varbinary
)
 
ASINSERT [Pictures] ([Title], [MIMEType], [ImageData]) VALUES (@Title, @MIMEType, @ImageData)
 
RETURN

View Replies !
Select Statement Using Multi-list Box Values For WHERE IN SQL Clause
I have a gridview that is based on the selection(s) in a listbox.  The gridview renders fine if I only select one value from the listbox.  I recive this error though when I select more that one value from the listbox:
Syntax error converting the nvarchar value '4,1' to a column of data type int.  If, however, I hard code 4,1 in place of @ListSelection (see below selectCommand WHERE and IN Clauses) the gridview renders perfectly.
<asp:SqlDataSource ID="SqlDataSourceAll" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT DISTINCT dbo.Contacts.Title, dbo.Contacts.FirstName, dbo.Contacts.MI, dbo.Contacts.LastName, dbo.Contacts.Suffix, dbo.Contacts.Dear, dbo.Contacts.Honorific, dbo.Contacts.Address, dbo.Contacts.Address2, dbo.Contacts.City, dbo.Contacts.StateOrProvince, dbo.Contacts.PostalCode FROM dbo.Contacts INNER JOIN dbo.tblListSelection ON dbo.Contacts.ContactID = dbo.tblListSelection.contactID INNER JOIN dbo.ListDescriptions ON dbo.tblListSelection.selListID = dbo.ListDescriptions.ID WHERE (dbo.tblListSelection.selListID IN (@ListSelection)) AND (dbo.Contacts.StateOrProvince LIKE '%') ORDER BY dbo.Contacts.LastName">
<SelectParameters>
<asp:Parameter Name="ListSelection" DefaultValue="1"/>
</SelectParameters>
</asp:SqlDataSource>
The selListID column is type integer in the database.
I'm using the ListBox1_selectedIndexChanged in the code behind like this where I've tried using setting my selectparameter using the label1.text value and the Requst.From(ListBox1.UniqueID) value with the same result:
 
Protected Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Dim Item As ListItem
For Each Item In ListBox1.Items
If Item.Selected Then
If Label1.Text <> "" Then
Label1.Text = Label1.Text + Item.Value + ","
Else
Label1.Text = Item.Value + ","
End If
End If
Next
Label1.Text = Label1.Text.TrimEnd(",")
SqlDataSourceAll.SelectParameters("ListSelection").DefaultValue = Request.Form(ListBox1.UniqueID)
End Sub
What am I doing wrong here?  Thanks!

View Replies !
Dropdown - Multi-select Won't Show Values If Only One Item Is Available
I have a report that has 2 dropdowns, selecting from the first dropdown populates the second one. This works fine in the BI Studio.

When I deploy this report to the 'Report Manager' and make a selection from the first dropdown, the second dropdown loads (as expected). I tried to select from the second dropdown (which has only 1 item - which is correct), the dropdown does not appear correctly - as in, I can't see that item.

Since we can't attach anything here, below is the link to a screenshot of my issue:
http://docs.google.com/View?docid=ddd6j2xn_52c5qd5

If you look closely at the screenshot from the link above, you'll see that there is a value in the second dropdown - it just won't show completely - as if the dropdown is not rendering correctly. I can view source on the page and see that the dropdown has a value.

What appears to be happening is the if only 1 item is in the second dropdown and that item is longer than the size of the dropdown, the dropdown won't render.

Here is my value for the second dropdown '012 Candy Gadler David Thapero'. This is the only value in the second dropdown. - You can try 35 chars or more in the dropdown to confirm.

Notes:
+ No special chars are in either dropdown
+ I am using IE 7 (Also had someone test this on IE 6 - same problem)
+ Using Visual Studio 2005 to build report - where this works fine

Work around:
+ If I add another item to the dropdown via a UNION query, I see the original value + the new item in the dropdown #2


Please share your thoughts
Thanks,
h.


 

View Replies !
Image Data Type
What save inside image data type field?
Thanks,mohsen

View Replies !
Image Data Type
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 Replies !
Image Data Type
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 Replies !
Image Data Type
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 Replies !
Image Data Type
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 Replies !
Image Data Type
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 Replies !
Image Data Type
Can anyone provide info on how to insert and store a .jpeg in a database table?
Thanks,
Kellie

View Replies !
About Image Data Type
Hi!
we know there is data type -- image, when i wanna input real image into these kind of data type, i usually use access to achieve this goal, but i think if i have no access, i will face to trouble!
could you tell me how i can input real image into image data type by means of SQL?
thanx very much!

View Replies !
Image Data Type
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 Replies !
Image Data Type
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 Replies !
How To Convert To Regular Text, Data Stored In Image Data Type Field ????
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 Replies !
Move Text Data (not A File) Into An Image Data Type
 

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 Replies !
The Size Of The Image Data Type
I'm using ODBC to interface a Microsoft SQL Server 2000. One of theoperations involves placing files within BLOBs. I'm using the imagedata type for this purpose. Most of the time this works okey, but whentrying to add a 21,3 MB file I get an error. The error code is 22001,which means "String right-truncation". But why? Does this mean thatthe field cannot accepts BLOBs with this size?

View Replies !
Image Data Type Size
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 Replies !
Operating On The Image Data Type
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 Replies !
DTS Transfer Of Image Data Type
DTS transfer of image data type always fails, log says that data is truncated in the image column. Can it be accomplished?

View Replies !
How Can I Read From Image Data Type
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 Replies !
How Can I Get The Image Data Type Size?
 

Hi,
 
   How can I get the Size of the image(binary)   data in the datatable?
 
   How can I get the size of the database through Query ? 
 
 
 

View Replies !
Contains Function On Image Data Type
Hi all,

I am working on application maintance. I got a Contains(myField, myString) that used to look into an image data type field (text) for the string, but right now it's not responding they way it's supposed to do.

Recently really big files have been introduced in the DB, could this related to the issue?

Anyone can help regarding this?

Many thanks,

Giovanni

View Replies !
Dealing With Data Type Image
Hi everyone,

Apology if this question doesn't belong to here.

I've created a table in SQL database with a field of type image, I also have a imge box on the web form where the user can browse for the file. So I need help in completing the code to replace the question marks.
===================================================================
Protected Sub cmdSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdSubmit.Click

Dim eSurveyAdd As New SqlDataSource()

eSurveyAdd.ConnectionString = ConfigurationManager.ConnectionStrings("CITSSurveyConnectionString1").ToString
eSurveyAdd.InsertCommandType = SqlDataSourceCommandType.Text
eSurveyAdd.InsertCommand = "INSERT INTO SurveyEntry (IT_LastName, IT_FirstName, PR_SnapShot, PR_Comments)
VALUES (@IT_LastName, @IT_FirstName, @PR_SnapShot, @PR_Comments)"

eSurveyAdd.InsertParameters.Add("IT_LastName", txtLastName.Text.ToUpper())
eSurveyAdd.InsertParameters.Add("IT_FirstName", txtFirstName.Text)
eSurveyAdd.InsertParameters.Add("PR_SnapShot", imgSnapShot.???????)
eSurveyAdd.InsertParameters.Add("PR_Comments", txtGeneralComments.Text)

Dim eProblemOccurred As Integer

eProblemOccurred = eSurveyAdd.Insert()
If eProblemOccurred <> 1 Then
Server.Transfer("FailedSave.aspx")
Else
Server.Transfer("SuccessfullSave.aspx")
End If
End Sub
===================================================================
(I'm still very new to SQL & Web developer).
Many thanks in advance.

Try your best, not enough ??, not your fault, just dive in desert.!!

View Replies !
Multi-Select String Parameter Values Are Converted To N'Value1', N'Value2' In Clause When Report Is Run
 

I understand that Multi-Select Parameters are converted behind the scenes to an In Clause when a report is executed.  The problem that I have is that my multi-select string parameter is turned into an in claused filled with nvarchar/unicode expressions like:
 

Where columnName in (N'Value1', N'Value2', N'Value3'...)
 
This nvarchar / unicode expression takes what is already a fairly slow-performing construct and just drives it into the ground.  When I capture my query with Profiler (so I can see the In Clause that is being built), I can run it in Management Studio and see the execution plan.  Using N'Values' instead of just 'Value1', 'Value2','Value3' causes the query performance to drop from 40 seconds to two minutes and 40 seconds.  It's horrible.  How can I make it stop!!!? 
 
Is there any way to force the query-rewriting process in Reporting Services to just use plain-old, varchar text values instead of forcing each value in the list to be converted on the fly to an Nvarchar value like this?  The column from which I am pulling values for the parameter and the column that I am filtering are both just plain varchar.
 
Thanks,
 
TC

View Replies !
Inserting Data Into Text Or Image Data Type
Hi all,
Pls tell me how to insert large data into text or image data type of MS SQL Server using Java.

Waiting for reply.........

View Replies !
Filling Image Data Type Field
Hi
I am currently working on an application that uses a stored procedure to retrieve data from a database and then display it in a web page.  My problem is that some of the data in the database will be images, I am currently putting in test data to test my code/procedures my problem is how do I put in test data for images, when I am finished I am going to add an admin section that will allow me to add images that way but how do I go about adding them to the database until then? I have set the field to the image data type but have no idea how to relate this to an image on my server?
Thanks, Adam

View Replies !
Image Data Type And Animated Gifs
I have an asp.net 2 app that retrieves images from a SQL Server 2005 Image field in our database. I have this working successfully apart from one problem. When I retrieve an animated gif, the animation is lost. Is there anyway around this?   

View Replies !
Copy Image Data Type From One Table To Another
Hi,
I've a column col1 of image data type in table1. I would like to copy the data from col1 to another image column col2 in table2. Before moving the value, checking has to be done to specify which col1 data from table1 is needed and the destination has to be checked too.

Example: insert into col2
(select col1 from table1 where table1_id =5)
where table2_id =6

Hence bcp wouldn't work. Can anyone suggest me a way to do it. I tried using writetext but then, i've to get data from col1 in a variable, which is not possible. Any suggestions would be very helpful.

Thanks in advance.
Ramya.

View Replies !
Hanling Image Data Type Columns
Hi
I have a table with image data type column. I would like to store photos (images in .jpg format) in the table. I am using ADODC to connect VB.NET with MS-SQL server 2000.

Thanzzzzzzzzzz... :rolleyes:

View Replies !
Storing Pictures In Image Data Type
Hey all,

Just starting to investigate this. I need to store digital pictures in my database for use in claims and disputes. I have played a bit with the image datatype but notice that one picture takes up 1Mb as a TIFF and 3Mb as a JPEG. Does anybody work with this stuff and if you do what is the best picture format to use in regards to keeping clarity but minimizing size used in the db. Is there any load conversion routines that would shrink the size of the file.

Any suggestions or comments on this topic are appreciated.

Thx. Kelsey

View Replies !
Storing Pictures In Image Data Type
Hey all,

Just starting to investigate this. I need to store digital pictures in my database for use in claims and disputes. I have played a bit with the image datatype but notice that one picture takes up 1Mb as a TIFF and 3Mb as a JPEG. Does anybody work with this stuff and if you do what is the best picture format to use in regards to keeping clarity but minimizing size used in the db. Is there any load conversion routines that would shrink the size of the file.

Any suggestions or comments on this topic are appreciated.

Thx. Kelsey

View Replies !
Image Data Type Insert From One Table To Another
Hi All

What is the efficient way of copying any table having Blob (Image Data type) items into another table with same structure .
I am trying with the following way and it is taking too long .
Table has 127000 rows ...
After 3.5 hours also it did not complete using following statement .

select * into NewSurveyItem from SurveyItem

--=======Table Structure ============

CREATE TABLE [dbo].[SurveyItem] (
[SurveyItemKey] [uniqueidentifier] NOT NULL ,
[SurveyKey] [int] NULL ,
[SurveyTypeSectionKey] [int] NULL ,
[RecommendIndicator] [bit] NOT NULL ,
[SectionHeader] [nvarchar] (75) NULL ,
[SectionSequenceNumber] [int] NULL ,
[SectionData] [image] NULL ,
[PrintFlag] [bit] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO



Thanks
Sujit

View Replies !
MsSQL Image Data Type Truncation
Hello, I am trying to store pictures in an Image data type column of my MsSQL table from PHP, or even SQL Query Analyzer for that matter. In PHP I use the bin2hex() function to get the HEX equivilent of the picture, I'm sure everyone knows that when you convert a Binary file to HEX, the file size is doubled. When I try to insert the HEX file into my table with a query like:
INSERT INTO PicTable (fileType, fileData) VALUES ('jpg', 0x47494638396164014100f70000000000ffffff2f2f2fe800020c0c0ce....)

MsSQL will store EXACTLY HALF of the file. The byte count of the stored HEX data and original Binary data is exactly the same, so when I try to extract the file and display it, in a browser window for instance, I can see exactly half of the image. I have tried everything I can think of to fix this, but I am at a loss. Does anyone know of anything that would cause this strange behavior. I have no problems at all doing this with MySQL's BLOB data type. Thanks in advance for any help.

View Replies !
Image Data Type And Animated Gifs
I have an asp.net 2 app that retrieves images from a SQL Server 2005 Image field in our database. I have this working successfully apart from one problem. When I retrieve an animated gif, the animation is lost. Is there anyway around this?

View Replies !
Help In Storing Binary To Image Data Type
Hi. how can i store binary data to another field with image data types.


here is my sample code


--note: [CUD_DOCUMENT] and [RES_DOCUMENT] are image data type

DECLARE @CUD_DOCUMENT binary

SELECT @CUD_DOCUMENT = CUD_DOCUMENT FROM CUD_CONTINUOUS_UPLOAD_DOCUMENTS

INSERT INTO [RES_RESUMES](
[RES_DOCUMENT] -- image data type
) VALUES (
@CUD_DOCUMENT)

thnx for the help.

View Replies !
Store 000 As Integer Data Type
Hi,Is it possible for me to store 000 or 01 or 001 in an Integer data type in SQL Server without it dropping the leading zeros?
Thanks

View Replies !
Which Data Type Should I Use To Store XML In A Column In DB?
I have xml string that needs to be stored in a field in the DB. I was looking for recommendations for the data type I can use in such a scenario.

View Replies !
Data Type To Store Photo
hello, 
I want to store the photo in the sql server 2005 , what datatype should I use?

View Replies !
Data Type To Store Time
Hi all ,

What datatype should I take to store time in a table -- datetime , float or decimal?

my requirement is to store "Worked Hours in a day by an employee" in the field say, 9 hrs and 30 mins.

I should be able to manipulate data in this field such as total hours present in the month, extra hours worked in a day (considering 9 hrs as standard time),less hours worked in a day, and so on

 

 

View Replies !
How To Store Image In Image Field In Sql Server 2000
 

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 Replies !
Storeing PDF's In SQL 2005 Using Image Data Type, Not Working...
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 Replies !
How To Set Up Search On Text Stored In An Image Type Of Data?
I am saving large text document in an image type of column in a SQL Server 2000 table.
How will I set up searching of words/ phrases for data stored in this column?

View Replies !
Using Image Data Type In A SQL Server 2000 Table
I have a recordset that joins five tables. Two of the tables contain afield that contains an image (a small bmp file 32x32 pixels).The join looks like this (omitting the other tables tha tdon't containgraphics)SELECT tblMain.UniqueID, tblMain.myField, tblGrahic1.ImageField1,tblGraphic2.ImageField2FROM (tblMains LEFT JOIN tblGraphic1 ON tblMain.ImageID1 =tblGraphic1.ImageID1) LEFT JOIN tblGraphic2 ON tblMain.ImageID22 =tblGraphics2.ImageID2The problem is this is extremely S-L-O-W on slow connections. If Iremove one of the table joins, it's much faster.I'm hoping someone can give me a better way to do this.The recordsource populates a continuous form in Access2K where thegraphics represent visually the settings made by users...Any help is greatly appreciated.lq

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved