Hi,
I need to read a pdf file which is on my hard drive and put it in the sql
server database. Once placed in the sql server, I again need to read that
file from the database and display it on the web? Is it possible? Could you
please provide some links where I could find the information?
Thanks,
Sridhar. 3 1363
Sridhar,
Look at the SQLServer datatype 'Image". You create a table with
column of type 'Image'. Then create stored procs to get/set the
Image datatype. On the .NET side, the byte[] can be used to plug into
the Image parameter to the stored procs. Here is a small example of
the call to the stored proc that will save the file into the table.
public bool UploadFile(User user, int formId, byte[] fileContents)
{
SqlParameter[] parameters =
{
new SqlParameter("@ FormId", SqlDbType.Int), // 1
new SqlParameter("@ FileContents", SqlDbType.Image ), // 2
};
// Set parameter values and directions
parameters[0].Value = formId;
parameters[1].Value = fileContents;
// Run the stored procedure
this.RunPersist SP("spJJK_RSMSc anForm__UploadN estorZDF", parameters);
}
--steve
Hi,
I found a link to do that. But I am having some problems. Here is the
code I am using to read the pdf file from a folder. It is doing PostBack
twice. I am not sure why it is doing that. If you have any idea please let me
know
Private Sub ReadPdfFile(ByV al strFilepath As String)
'Create WebClient Object
Dim objWebClient As New WebClient
'Create Byte Array to download data
Dim byteBuffer() As Byte = objWebClient.Do wnloadData(strF ilepath)
'Read Data
If Not byteBuffer Is Nothing Then
Response.Buffer = True
Response.Conten tType = "applicatio n/pdf"
Response.AddHea der("content-length", byteBuffer.Leng th.ToString())
Response.Binary Write(byteBuffe r)
End If
End Sub
I am thinking it might be due to Response.Binary Write(). Is there any
solution to this?
Thanks,
Sridhar.
"n33470" wrote: Sridhar,
Look at the SQLServer datatype 'Image". You create a table with column of type 'Image'. Then create stored procs to get/set the Image datatype. On the .NET side, the byte[] can be used to plug into the Image parameter to the stored procs. Here is a small example of the call to the stored proc that will save the file into the table.
public bool UploadFile(User user, int formId, byte[] fileContents) {
SqlParameter[] parameters = { new SqlParameter("@ FormId", SqlDbType.Int), // 1 new SqlParameter("@ FileContents", SqlDbType.Image ), // 2 };
// Set parameter values and directions parameters[0].Value = formId; parameters[1].Value = fileContents;
// Run the stored procedure this.RunPersist SP("spJJK_RSMSc anForm__UploadN estorZDF", parameters);
} --steve
Sridhar,
Try this block of code to send the file to the browser:
Response.ClearC ontent();
Response.Conten tType = "applicatio n/pdf";
Response.AddHea der("content-length", byteBuffer.Leng th.ToString())
Response.Binary Write(byteBuffe r);
Response.Flush( );
Response.Close( );
Notice the call to clear the response stream first, this will remove
any other html that might already be on the stream. Next, the
Flush()/Close() is important so that it sends the data to the browser
and ends the processing of the page. I've personally never used
BinaryWrite(), but I would not think that would be your problem.
HTH,
--steve This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Tommy |
last post by:
Hi
I've uploaded the .aspx files and Web.config file made in
VS.NET 2003 but I get this error http://empty-
site.org/Login.aspx . I did change the config file as
mentioned but with no luck . can somebody help ?
TIA
Tommy
|
by: Alan Silver |
last post by:
Hello,
I am just looking at VWD and seeing what needs doing to take an existing
site I've written by hand and importing it into VWD. I've already
discovered that I need to rename my code-behind files to match the .aspx
file name so VWD will tie the two together, and I'm now wondering what
to do about the location of the code-behind files.
Is there any set convention for where the code-behind files live? I have
been putting them in the...
|
by: Tommy |
last post by:
Hi
I've uploaded the .aspx files and Web.config file made in
VS.NET 2003 but I get this error http://empty-
site.org/Login.aspx . I did change the config file as
mentioned but with no luck . can somebody help ?
TIA
Tommy
|
by: pob |
last post by:
I currently have a procedure that loops thru a recordset to determine
what files need to be loaded to my database. The naming convention of
the files has always been accounts.txt, namelist.txt, etc. Within the
procedure I also validate that the file loaded to the server was loaded
within the current day. Everything has run smooth for quite some time
using this method.
Now the vendor has told me he has choice, but to the send the file...
|
by: =?Utf-8?B?QnJ5YW4=?= |
last post by:
Hello group.
I have some code (given to me), but I don't know alot about ASP, so I was
hoping someone here can help. Running on Win 2008 server.
The code below will scan a folder and subfolder with a date/time input and
return xml structure off all files that are newer than the supplied date/time.
The problem is that the returned xml has path names like
C:\folder\subfolder\filename.ext
I would like it to be more like...
| |
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |