Tuesday, May 27, 2008

Using Excel Sheets as a Database Backend

http://www.beansoftware.com/NET-Tutorials/Excel-ADO.NET-Database.aspx

How to remove duplicate rows from a SQL Server table by using a script

SELECT DISTINCT * INTO duplicate_table FROM original_table GROUP BY key_value HAVING COUNT(key_value) > 1

DELETE original_table WHERE key_value IN (SELECT key_value FROM duplicate_table)

INSERT original_table SELECT * FROM duplicate_table DROP TABLE duplicate_table

Tuesday, May 20, 2008

Connection to XLS using .NET

It is the simple program. it explains how to connect MS-Excel Database.
Background
Creating Table in Excel is very simple and easy. also fetch from Excel table is also very easy.
Using the codeFor Connect the Excel, we have to use the normal OLEDB connection as follows :
Collapse string Con_Str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + DB_Path + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\";";

Here DB_Path is the location of the .XLS file.
"HDR=Yes;" indicates that the first row contains columnnames, not data."HDR=No;" indicates the opposite.
"IMEX=1;" tells the driver to always read "intermixed" (numbers, dates, strings etc) data columns as text. Note that this option might affect excel sheet write access negative.

License