i have an excel sheet where i try to upload my excel sheet to sqlserver all having same colum name.
now i do not want to add dll files as an web reference in my project.
rather place the (dll) in an folder and call them dynamically in .cs side.
now i am doing like this
var assembly = Assembly.LoadFrom(#"d:\abc\microsoft.office.interop.excel.dll");
now in my .cs page i need to generate this property or methods of an excel dll which i have loaded dynamically
microsoft.officce.interop.excel.applicationClass excel= null
so that after loading my excel dl dynamically i need to sent values from my excel sheet to sqlserver 2005
is there a way to achive this
thank you
Can you not use OPENROWSET?
i.e Create a stored procedure that takes the path of the excel file which you want to insert into a given table. Use OPENROWSET function inside it to get a hold of the excel sheet.
Aother option is to possibly use SSIS to do this (SQL Server Integration Services). You would have more flexibility and could turn it into a small ETL project.
You could also use Excel code to transmit the data to the database either with a button or a macro. That only works if you can control the Excel file.
Just throwing other options out there.
First add a linked server to your Database instance..
Exec sp_dropServer 'myExcel',#droplogins='dropLogins'
EXEC sp_addlinkedserver 'myExcel',
'ACE 12.0',
'Microsoft.ACE.OLEDB.12.0',
'D:\SAABZX01D\EXCEL_books\ExpressLane\LMI\client carrier conversion.xls',
NULL,
'Excel 12.0'
exec sp_linkedServers
Then you insert to myTable in yourDatabase
Insert myTable(cola,colb,colc)
select cola,colb,colc from openQuery(myExcel,'select cola,colb,colc) from sheet1$')
You can open an excel file like a database (described here). After this you can load the data into some DataSet (I hope you know how to work with datasets) and upload all to the SqlServer database or to load in some custom structures, update some data if need and insert it into SqlServer database.
Related
Teradata Studio Express, Version 16.2
I queried from an oracle database using TSE's SQL file editor (Since it is a non-TeraData database or else I would be using TSE's Teradata SQL editor). When querying from SQL File Editor, TSE provides the result within the SQL Results panel.
What I want to do is to export the result to an excel file but it does
not provide an option to do so. How do I approach this?
Below is a screenshot comparing result set panels. The left panel (querying from Teradata SQL Editor) has an option to export to excel but the right panel (Querying SQL File Editor) does not.
Finally figured it out.. Don't know why they don't provide a export option icon yet but here is solution:
Right click on the result table.
It will provides options. Select Export, then Current Result...
Then this window will appear (save it as a csv file and you should be able to open with Excel):
I am creating an application which will upload data from Excel to SQL Server using ASP.NET. I know how to upload Excel data using SqlBulkCopy. But I am trying to upload some extra data for the table column (addeddate, addedby...etc) which is not present in the Excel sheet.
I get this error:
The given ColumnName '18-01-2016 17:24:07' does not match up with any column in data source.
You can try below solution to insert constant values like addeddate, addedby...etc.
SELECT
EXCEL_COL1,
EXCEL_COL2,
'newconstantvalue' as CustomCol
FROM
ExcelSheet1
Then
bulkCopy.ColumnMappings.Add("Table_COL3", "CustomCol");
Please refer the article for more detail.
I have Uploaded a file into server and I want to read the data from that file and insert data into the oracle. I am using a list for taking the data from the file and Data is reading from this List. No problem with my code. It reads completely and data's are inserted into the oracle table Locally.. But After Hosting the data's not completely inserted to the table..After inserting some data it become stuck.
I have an Excel sheet with more than 1000 records with customer details such as name, tele, address ...etc. and I want to know if I can save this sheet into a SQL Server database without inserting these records one by one from an aspx page, as I will have table in the database with customer details.
You can use SSMS's Import Data option, and use Excel as a data source and the table as the destination. This is a "run once" option. The second option, if you have to run this frequently, is to create an SSIS package for the import.
How to send datatable as a parameter to mysql store procedure through asp.net code.
if any solution is there, can anyone please tell me. Its urgent
thank you,
You could write it to a .csv and use LOAD DATA INFILE
- LOAD DATA INFILE Syntax
Else you you have to loop through the datatable and insert one by one row.
References
Best way to Bulk Insert from a C# DataTable
I would parse the data set and for each data row call a stored procedure passing parameters for one data row. If you don't want that, then there are other import facilities (bulk import) like http://brockangelo.com/2009/04/27/how-to-bulk-import-into-a-mysql-database or MySQL bulk insert from CSV data files.