Excel sheet to store into database - asp.net

I want to know how to store the excel sheet(like payslip it's contain image also) into sql server 2005 database using asp.net
Please guide me.

Look at using a BLOB field:
http://www.codeproject.com/KB/database/Store_and_manipulat_BLOBs.aspx
or just store the sheet in a properly protected directory and serve it up via a ASHX handler when needed.

If you were using SQL Server 2008 or later, you would also have the option of using FILESTREAM storage.

We use varbinary(max) for storing documents in sql server. Load the document as a byte array.

Related

Is it possible to store a pseudo SQL Server database for my ASP .NET project?

My ASP.NET project is using SQL Server as the database. I am wondering if it is possible to store a temporary instance of my database so that I would only need to query once to work with the data that I need. For example, I will query the 2 tables, Person and Students with a common id. I want to be able to join the tables and use the information.
I think there are some solutions:
Store the tables in the front end and use ajax javascript to manipulate the tables information.
Store in a txt file or similar file on to the project folder as a pseudo database.
Would love to hear any ideas!
You could do worse than consider SQL Server Compact edition:
https://www.microsoft.com/en-za/download/details.aspx?id=17876
Which has a small footprint and supports private deployment of its binaries within the application folder
EDIT:
It seems CE is deprecated since last I used it. and MS now recommend SQL Server Express Local DB
https://learn.microsoft.com/en-gb/sql/database-engine/configure-windows/sql-server-express-localdb?view=sql-server-2017
And there is also SQLLite: https://www.supinfo.com/articles/single/6941-an-aspnet-core-mvc-app-with-sqlite-and-entity-framework

What is the Better Idea to store Images?

What would be the better Idea to store Images ? Is it Database (or) any hosting ?
(or) Is there any other idea to store images using ASP.net.
The standard answer is to use both; database holds the location of the files and the file server holds the actual data.
The main advantages of doing this are listed in Store pictures as files or in the database for a web app?
If you are using SQL Server and version 2008 or higher then its worth to store image in file stream. It contains both advantage of storing image in files and database.
Here you can find more information about it from following links.
http://technet.microsoft.com/en-us/library/bb933993(v=sql.105).aspx
http://www.codeproject.com/Articles/128657/How-Do-I-Use-SQL-File-Stream
Regards,

Storing and retrieving images in sql server 2005 in asp.net via c#

How do I store and retrieve images in sql server 2005 in asp.net with c#
You may store them as binary data.
You may write a module (derived from IHttpModule), register it for RequestBegin event.
When request come you may retrieve data from database, store it on disk with requested file name and
this image will automatically be returned by built-in IIS handler (which is written in native code and works very fast).
Here is a project that does just the thing. All you need to do is move the storing and retrieving logic into your ASP .Net application.
It is not recommended.
Best practice is storing meta-data (here meta-data is you image file name) inside database and sotre them on file-system (for example c:\images). Then when you need an image you can ask database for its name and retreive it from file-system.
This helps you to have a compact database and maintenance became easy. Handling large databases backup/restore is a headache.

storing image in Db using asp.net

Im developing art gallery which needs 1000s of images to be uploaded so inserting images in DB won't be feasible. so i want to give link of folder inside db where ultimately images should get stored. plz help.
so inserting images in DB won't be
feasible
Why? Works very nicely. Especially with 2008 where you then dump them into a file system store again transparently.
I have a datas store where I store about 500gb of binary information all stored within the database. No issue at all.
Actually if you are using SQL 2008 you can use the FileStream mechanism, which actually stores the images as files on disk, but can be returned in sql results, so the data is still relational.
But answer aside, there's nothing wrong with storing 1000's of images in the database. But worst case, just store the string link if you really want.. its just that process is a little archaic.
It all depends on the DB that you're using I suppose (you didn't mentioned which you're using)
You can always store a relative path to the image file.
For example you might store images at UNC location of: \\YOUR_SERVER\myApplication\images\image1.png
-> the relative path would just be \myApplication\images\image1.png
(By storing just the relative path to the file, you're isolating the possiblity that you might change the server location in future.)
If you are using Sql Server 2008, then checkout the FileStream feature. More background info here.
One of my sites stores all user uploaded images in sql server and it works great. The only problem I can see if you are using shared hosting where you don't get a large database. Otherwise I think its a great option.

generate excel sheet from a excel template in asp.net using vb.net

i need to generate an excel sheet from an excel template which contains drop down lists. I need to use the template and populate the with data from datbase and select the appropriate value from the drop down lists and generate the new excel sheet. I am in very bad situation and need it asap.
try spread Sheet Gear third party component
http://www.spreadsheetgear.com/
OR
http://www.smartxls.com/
You have a few options:
Third-party component ($$$) to read, modify, and send the Excel file.
Office COM automation on the back-end (bad idea. Really. Don't do it).
Save your template on the server as an XML Spreadsheet file (the XML format used by Office 2002 and 2003 and still supported in 2007). Since it's a single XML file, it can be easily read by server-side code, modified on the fly, and redirected back to the user.
Save your template on the server as an XLSX file (the newer XML format used by 2007) and modify it on the way out to the user. Much more complicated since there's a ZIP wrapper and multiple XML files involved.
Save your template on the server as a normal Excel 97/2000 file (not 2007), and when the user requests it, make a copy of the file on the server (requires write access) with a random name, open an database connection using the Excel OLEDB driver to the Excel file, perform INSERT statements into it (goes into tabs of those names, where you store your drop-down values), close the connection, and send the file. Caveat: the Excel OLEDB driver has some limitations.
Go the other direction. Use Excel's web data connection capabilities to access the server after the Excel file is already on the user's machine and open to grab the appropriate values from the server. Requires some user training to refresh the data.

Resources