473,405 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Validating and uploading excel in database

Hi.
My project requires to upload the excel file and populate it into
the database. By doing so it should also check whether the excel file
selected is in the right format.

for example if the file contains the Name , Address and Age fields.

Then the Name , Address column should accept all characters while the
age column should accept only numbers

The columns also should be in correct sequence.
I would be glad if some one provide me some hint how to do so..

Thanks for replying me.

Sep 6 '07 #1
4 7725
Would csv (via Excel) suffice? If so there are some great (fast and
free) CSV readers that you can use on an uploaded file (Request.Files)
- e.g. www.codeproject.com/cs/database/CsvReader.asp; you can attach
the csv-reader to the .InputStream (of the file), and read over the
data. Now the clever bit: you can use an IDataReader (which this is)
as the input to a SqlBulkCopy operation (if you are using sql-server),
and essentially BCP the data into the database. Personally I'd bulk-
insert into a staging table, and then execute a stored-procedure to
merge with live data.

For validation; could rely on the databaes parser; could BCP as
varchar, then valdiate (ISNUMERIC) at the database, or could inject a
validating reader so that you check each row as SqlBulkCopy asks for
it (trickier, but still easy).

If you must use Excel, then you need either to save it locally and use
ADODB to open it (slow), else look into Excel parsers. Personally, I'd
go for csv if it is an option.

Marc

Sep 6 '07 #2
thats sounds good. but all of sudden the requirement has been changed,
now my boss wants that the form should contain the excel component,
The user will make changes in the excel file .
And then the same excel file will be saved in the database. May be i
will parse the file. or save the object of excel itself.

There is a method through which we create an excel on web page by
flushing the html code below is the sample code which i have tried

Dim dsExport As New DataSet()
Dim tw As New System.IO.StringWriter()
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
Dim dgGrid As New DataGrid()

dgGrid.DataSource = getData()

' Report Header
hw.WriteLine("<b><u><font size='5'Student Marking Report </
font></u></b>")

' Get the HTML for the control.
dgGrid.HeaderStyle.Font.Bold = True
dgGrid.DataBind()
dgGrid.RenderControl(hw)

' Write the HTML back to the browser.
Response.ContentType = "application/vnd.ms-excel"
Me.EnableViewState = False
Response.Write(tw.ToString())
Response.End()
Now i want the changes should be saved in the database .. How will do
so....>?????

Sep 24 '07 #3
Your boss needs to be realistic; that will be prone to /so/ many
issues; client install, concurrency, write access... perhaps something
like google docs would be a better fit? or alternatively, sharepoint
with office integration?

Marc

Sep 29 '07 #4
Tried to do hands dirty with OWC (Office Web Component) and it worked
well. It proved to be the right solution for the purpose. Just gave
the POC on OWC. and waiting for the Global IT approval team for the
suggestions . But still I would like to have few more solutions on the
same pathway.
Oct 2 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Rahul Chatterjee | last post by:
Hello All I am uploading a file using ASP code. After the user uploads the file, I would like to be able to open the file and check if the data is in a given format (comma separated) and also...
0
by: ml | last post by:
If anyone could show me code how to upload excel data from the client to a sql database on the server
0
by: Ramakrishnan Nagarajan | last post by:
Hi, I am facing a problem in uploading Excel data to the Database. While uploading my code reads Excel Data using OleDbReader and store into a dataset by looping through the OleDbReader result...
3
by: Charlie | last post by:
Hi: I'm working on an application that uploads images into binary fields on SQL Server. Before submitting, I would like to validate size of image (ie, 75 pixels by 75 pixels) so that images are...
1
by: lipsa | last post by:
hello all, 1-i m uploading an excel sheet(VB/ASP.NET).before uploading i want to check if the file to be uploaded is opened or not.if opened alert the user.i want to do it at the client side(using...
6
by: chiya | last post by:
plz anybody help me in uploading data from excel file to mysql database. data in excel sheet is in vertical format not horizontally. I mean to say that the columns of mysql tables are in rows in...
0
by: upadhyayanuj | last post by:
Hi I have an error while uploading file and then importing it into my sql table The process cannot access the file 'c:\inetpub\wwwroot\FlowLine\Excel File\Fan_Details.xls' because it is being...
2
by: matech | last post by:
I have a problem with uploading special characters from excel files to mysql 5. It doesn't matter if I use UTF-8 or iso-8859-1 when uploading the trademark ™ symbol. htmlspecialchars() or...
5
by: Tempalli | last post by:
I am uploading MS Excel data to Ms access as detailed below. Ms. Excel A(Column) B(Column) C(Column)...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.