Importing Excel Table into a MS SQL Table - asp.net

I have software for STOCK and SALES that can give me an Excel price list, I wanna write a small web app that will enable users to check prices, I don't have any access to that software's database, so I wanna import that Excel data (one worksheet, 5 columns, almost 10000 rows) into an MS SQL database table, keep in mind that the price list will change few time a month so I need to re-import that price list once its been updated.
Any suggestions? or maybe I should skip using an MS SQL database and directly use the Excel sheet? if so, then how?!

I'd go directly to SQL Server. Let it do the heavy lifting. If one of your users wants to export data to Excel, by all means provide such a feature. But multi-user changes to the data should be done in SQL Server via the web. Excel should be a local, read-only, personal copy to download and nothing else.
SQL Server can easily import an Excel spreadsheet or .csv file, especially if we're talking about a single table with five columns. I'd still have SQL Server do all the work on the web side.

If you save the Excel file as a CSV, it doesn't take much of a program to convert that into SQL statements.

You can use bulk upload to upload data from excel to sql server. Please look at the link below
http://www.gyansangrah.com/ArticleContent.aspx?ID=bulk_upload_in_asp_net
Please let me know in case of any issues.

Related

Any way to convert Realm database file in to sqlite?

I have realm database (.realm) from an existing application, which has more than 400k records.
I dug my head in to this for more than 3-4 hours, but I couldn't find any fruitful results towards converting a .realm file in to a sqlite file.
Any data conversion so far has been done manually. People have converted from Core Data to Realm by grabbing the objects from Core Data and then saving them to a Realm.
I imagine your best bet will be similar here. Grab each object from the Realm and then convert it to the tables/rows/and columns in sqlite. Then you can take that file anywhere.
You can open the realm file in Realm Browser & there you have the option to convert the file in to CSV ( File => Export => CSV ). Then you can import that CSV file to mysql database.
If you want sqlite more specifically, You can import tables separately to your sqlite db through SQLiteBrowser . Create or open your database file and select the specific table you want , then you can import table from CSV.
I'm not at home with this, but I found this link hopefully it can help.

Inserting Text File into Database

I have visual studio 2010 with sql express. Im trying to create a asp website that will display a file from a database, and need to insert a textfile or pdf into the database table, can this be done using the visual interface, all the intructions i have found is only using the sql insert command?
Thanks
No you can't do this. Basic UI interface means you can type it in, you can't type in an array of byte.
So that means code, it's not hard, but I would recommend you consider storing the a url / filename in the table and then putting the file on the file system instead of as a blob in the table.
Files in database blobs does have some benefits for local deployment, in that you don't have to worry about some muppet making them inaccessible. Server side though that is far less of a worry. As long as you back up database and file system and come up with a reasonable directory and file naming structure its much less of a cost than bloating a database with a load of stuff you can't use in a query, not to mention it tends to make a fair mess of volume (mdb) file.
Oh and there are persistant rumours that MS are going to drop blobs over 8000 bytes as well.

How to update MYSQL Database with data from Excel using ASP.NET?

I have an excel file which gets updated every 10 seconds through an automated process. I need excel data to be updated in MY-SQL database which is located on a remote server.
How do I do that?
I have thought of following option:
1) Every 11 seconds, an Excel macro will run and will "Save as" excel as CSV file. (not sure whether this can be done by macro...just thinking)
2) This CSV file we will FTP to remote server using Windows Service.
3) On remote server, we will parse the csv file and Update MYSQL database.
Is this approach fine? Or do you have a better approach which requires less time to update the database?
Thanks!
I found following links to be more useful:
http://www.heritage-tech.net/908/inserting-data-into-mysql-from-excel-using-vba/
http://vbaexcel.eu/vba-macro-code/update-mysql-database-php
I hope this helps someone having similar problem as mine.
You can connect to the Excel spreadsheet using ODBC connection, read the data, and post it to the MySQL database, maybe through some sort of web service access, or via a saved CSV file?

Exporting MS SQL Schema and Data

I'm used to MySQL and PHPMyAdmin - I had to switch over to MSSQL for an ASP.net project, and I'm having tons of trouble. I'm using the express version of SQL 2008, with SQL Server Management Studio. The following are 2 questions I've been struggling with for a while:
1) How do I export the DB schema for the database? The table structure, etc.?
2) How do I export all the data in the database?
Ideally I'd like to have a .sql file that can be run wherever I need the schema or data duplicated, for example a co-worker's computer for a shared project, or online when the project is being hosted.
Thanks!
1) How do I export the DB schema for the database? The table structure, etc.?
INFORMATION_SCHEMA is your friend
SELECT * FROM INFORMATION_SCHEMA.TABLES
http://www.mssqltips.com/tutorial.asp?tutorial=179
http://weblogs.asp.net/jgalloway/archive/2006/07/07/455797.aspx
http://preetul.wordpress.com/2009/06/09/sql-server-information_schema/
Otherwise, if you want something pretty looking, download the 14 day trial of SQL Doc (part of SQL Toolbelt) here:
http://www.red-gate.com/products/SQL_Professional_Toolbelt/index.htm
"2) How do I export all the data in the database?"
In what form? .bak files are typically the most useful. http://www.sqlteam.com/article/backup-and-restore-in-sql-server-full-backups
Or were you looking to move the data into MYSQL or Excel or some other program? If you want to move data to MYSQL check here: http://www.google.com/search?q=mssql+to+mysql

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