I already uploaded pdf files into my sql database as binary data file. I want to retrieve this file and open it with Adobe Reader on my form. But I couldn't solve it in C# code.
I want to retrieve the pdf file which id number = textbox1 and I want to load that file to axAcroPDF1 Adobe viewer.
I want to write this code to form load action.
textBox1.text= clipboard.gettext();
then retrieve code.
You first need to retrieve the data from the database in the same way as you would any other data. That will give you a Byte array. You can then call File.WriteAllBytes to write that data to a file. You can use the Path.GetTempFileName method to create a temp file to write the data to if appropriate. You can then use that path to open the file in your PDF reader as you normally would.
Related
I have a SQL Server 2008 database from an application which stores office file templates.
The files in the database are stored in hex format (0x504B030414000600...).
With a file signature table (https://www.garykessler.net/library/file_sigs.html), I can find out which file format it is: Microsoft Office Open XML Format Documents (OOXML, like DOCX, PPTX, XLSX ...).
How can I export/convert these hex strings into the original files?
Maybe with C# ...
With the application itself, I can only export 1 file at a time. It would take days to do this with all files (about 1000).
Thank you
Export column with files from SQL Server to single file (it may be very large, but it shouldn't matter). You can for example right click and export results to CSV file.
Write simple C# console application:
use CSV parser to loop over data
inside loop you can make simple if statements to determine document file format
in every iteration convert hex format to blob file and save it somewhere on your drive
I am using EasyGis.net to load a shape file in my desktop application.
I want to save this file in database so that i can use this file from the server side of my software.
I am able to save normal .png files in database by converting image object into a byte array.
Now i need to save the shape file so that i can use this from my server.
You can use this function:
File.ReadAllBytes(fileName);
Ref: https://msdn.microsoft.com/en-us/library/system.io.file.readallbytes(v=vs.110).aspx
I would like to use abcPDF (.net) generator to output a stream of data from a DB into a PDF file that can then be output as a file via button. I know that abcPDF can be used to output a file independently, but I would like to generate data from a survey, populate a DB, and then later on, the user can generate a PDF that has data charts that can be streamed into the pdf as bits from an image made by .netCharting.
Any possible solutions using these two?
Thanks!
I think you are looking for doc.AddImageData() which will allow you to pass the data from the db to create a pdf file.
I want to develop an application which reads data from an MS excel file which is opened.
I want to develop this application because the data is updated for every one minute in the cells present in it and i cant see it again if i want to see. so i want to read the file data and save it in a text file or an ms access file.
I know how to save it but i dont know how to read the ms excel file which is opened.
There would be a great appreciation if someone could help me.
Thanks In Advance.
If I understand your query, you'll need to open the file in read only mode to prevent any access violations from occuring.
(eg. Your app saves some new data and then the open file is saved, removing your saved data)
If you are opening it in read-only, you'll need a refresh timer that will check for revisions of the file. It would only update if the Excel file is saved as you would not be able to access the memory location of an unsaved file.
Perhaps saving your data as .CSV will be easiest to read in to your app. Excel will allow you to save as this type and it is easy to read in C#, using a normal file stream.
Hope this helps.
I have a tab delimited text file that I need to upload to a secure folder for SSIS to import into SQL Server. The file will be uploaded by an external user VIA a web app.
My challenge is that I need to check this file for some things before I am allowed to let it go to the secure folder. Namely I need to make sure the user has a specific column.
I can do this if I save the file to a folder in the web app. However the nature of the data in the file is such that we do not wish to place this file anywhere other then the secured folder. I also can not place it directly to this folder because the SSIS package is set to trigger as soon as the file shows up there.
What I need to do is find a way, if there is one, to parse the file in memory and if it passes all the checks, upload it to the secure folder.
I'm using C#.NET and the FileUpload Control.
My search so far has included all kinds of information but they all require saving the file somewhere first and then working with it.
Thank you so much for your time. If anybody can point me to an object or some code I can check out I would be most grateful.
Rather than calling SaveAs, use the FileContent property to access the contents of the file as a Stream, then you can do whatever processing is required before you save it manually.
For example, something like this:
string data;
using(StreamReader reader = new StreamReader(fileUpload.FileContent))
{
data = reader.ReadToEnd();
}
The data variable now contains the contents of the file as a string. You can do whatever processing you like, then save it (or not) to the appropriate location.