I need help in making the following application.
My requirement is -
1. The user have an excel sheet (.xls or .csv) files.
2. The user logs in the system and uploads the file. (Using File Upload button).
3. User clicks "OK" Button.
4. On this button, I have to fire an UPDATE and INSERT Query.
-----------
Queries depend on the data in excel sheet.
-------
The excel sheet is as follows (with 4 columns) -
------------
| ID | Serial Number | Item Code | Item Name | Assigned To |
| 1 | I1 | C1 | Mouse | Sunil |
| 2 | I2 | C2 | Keyboard | Ajinkya |
| 3 | I3 | C3 | Keyboard | Aditya |
Now, on the button click, the system will fire the query as -
Update tablename set itemcode = Item Code, Item Name = Item Name, Assigned To = Assigned To where Serial No = Serial Number
If Serial Number is not there in the database table, then
Insert into temptable (Serial Number, Item Code, Item Name, Assigned To) values
(Serial Number, Item Code, Item Name, Assigned To)
-----------
Points:-
1. I have to use stored procedures. I cannot write queries in aspx.cs file.
2. File extension can be - xls, xlsx, or csv .
-----------
Please help.
Its a bit urgent.
Thanks a lot in advance...
Riddhi ValechaPosted Oct 21, 2014, 3:32 AM
I am getting an error -
The Microsoft Office Access database engine cannot open or write to the file ''. It is already opened exclusively by another user, or you need permission to view and write its data.
Riddhi ValechaPosted Oct 20, 2014, 4:55 AM
I visited the link
I do not have to use SQLBulkCopy.
Also, first I have to check whether the column-1(SerialNumber) exists in the table or not.
If yes, then update.
If no, then insert.
Please let me know of you have some working code for the same.
Blocked AccountPosted Oct 20, 2014, 4:19 AM
Take the reference of this article.
Import Excel Data to SQL Server in ASP.NET