Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 23rd, 2008, 06:14 AM
Authorized User
 
Join Date: Jul 2008
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to TashaAT
Default

I changed the code behind to:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class ProductUpload : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void ButtonUploadFile_Click(object sender, EventArgs e)
    {
        FileUploadExcel.SaveAs(Server.MapPath("~ExcelImpor t.xls"));
        LabelUpload.Text = "Upload File Name: " +
FileUploadExcel.PostedFile.FileName + "<br>";
        FileUploadExcel.PostedFile.ContentType+ "Files Size:";
        FileUploadExcel.PostedFile.ContentLength+"kb <br>";

Now it only gives me two errors :) PROGRESS!
Only assignment, call, increment, decrement, and new object expressions can be used as a statement and it is for both
 FileUploadExcel.PostedFile.ContentType+ "Files Size:";
 FileUploadExcel.PostedFile.ContentLength+"kb <br>";

 
Old July 23rd, 2008, 06:16 AM
Authorized User
 
Join Date: Jul 2008
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to TashaAT
Default

I just have to say you guys are AWESOME I live in South Africa and I always find it really hard to get help online - never mind such FAST responses!!!
:D
THANK YOU SO MUCH!!!

 
Old July 23rd, 2008, 06:22 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

Happy to be of help :)

I dont think I am alone here when I say:
"The more people actively using the forum and wanting to learn (not "please send code") the better."

Please give us a shout if you get stuck again.

On a side note:
I would strongly recommend getting youself a reference book though..
I find it invaluable when getting to grips with new things to actually
sit there and work through a chapter or two with examples. Yeah,
sometimes you hit duplicate stuff, but actually running through basic
examples can often get you asking questions in your own mind that can
lead on to better things ;)

Rob
http://cantgrokwontgrok.blogspot.com
 
Old July 23rd, 2008, 06:31 AM
Authorized User
 
Join Date: Jul 2008
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to TashaAT
Default

I actually just got the digital download
ASP.NET 2.0 Website Programming: Problem - Design - Solution


 
Old July 23rd, 2008, 06:36 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

Ah! Cool :)
Good thing about online docs is that you can search quicker :)

Take it from me though, NEVER underestimate the value of getting away from the screen with a tea/coffee and just reading ;)

Rob
http://cantgrokwontgrok.blogspot.com
 
Old July 23rd, 2008, 12:13 PM
Authorized User
 
Join Date: Jul 2008
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to TashaAT
Default

I stepped away from the screen

But now I am back and...
I have done the form and I can now upload an excel spreadsheet BUT I now want to show this data in a grid view!
(Never make it to easy :) )

So I assume I need to start looking at Connection Objects?
But everything I look at is SQL SQL SQL?
Can I do Dim xConnStr AS String?

 
Old July 24th, 2008, 02:10 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

Great, glad to hear you are making progress.

So we have the xls file uploaded to the server and stored away ok right?

Great, so then we need a way to open the xls file and parse its data, and commit it to a database for storage.

As some pointers:

You need to understand what a ADO.NET Data Provider is (specifically the Sql Server flavour as that is that you will be working with).
Now personally, I have not done much xls parsing with .NET, my first instinct would be to grab the PIA's and open up the xls file using the Excel DOM but, I am pretty sure you need Office installed on the server, and I am not too sure what the performance/reliability would be like in that environment (only done it via Windows apps). Other than that, you would need to understand the file structure to be able to extract the data from it.

Perhaps someone else could offer more insight there?

But yes, definately need to get your head round ADO.NET and the Sql Server Data Provider. If you have any queries with these, then please ask :)

Rob
http://cantgrokwontgrok.blogspot.com
 
Old July 24th, 2008, 02:53 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

You have two main choices if the Excel file is a binary one, if it's the more modern XML format then that offers another possibility.
 
  • Open the file using Excel automation, this has the advantage of reasonable simplicity but requires Excel on the server and is notoriously flaky. It's not supported by Microsoft and unless you're very careful then an error can freeze the whole application.
  • Connect via an OleDbProvider. There are specific connection strings for Excel, see www.connectionstrings.com. The trouble with this method is that the provider has to guess the data types from the initial rows of data and often gets it wrong. Depends on what your file contains.

Either way, once you have the data I would put it into a real database for manipulation, searching etc.

--

Joe (Microsoft MVP - XML)
 
Old July 24th, 2008, 02:56 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

OleDbProvider of course! :) I knew there must have been a better way! I would have been against using automation on a web server! :)

Thanks Joe!

Rob
http://cantgrokwontgrok.blogspot.com
 
Old July 24th, 2008, 03:21 AM
Authorized User
 
Join Date: Jul 2008
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to TashaAT
Default

What I need to do is have a spreadsheet where the client can capture all their products and then do a bulk upload this will then update stock levels prices and add new items.
This spreadsheet will then get pulled into the SQL DB.
Okay now I need you to move a few steps back here what do you mean by OleDbProvider?






Similar Threads
Thread Thread Starter Forum Replies Last Post
import excel to access Vision G Access 1 October 15th, 2008 02:12 PM
Import From excel with n sheets dbellavi SQL Server DTS 1 September 11th, 2007 07:51 AM
newby Tyler Access 1 December 14th, 2005 07:29 AM
Excel IMport Text Help!! money Excel VBA 2 April 30th, 2004 12:43 AM
Excel Data Import bmains ASP.NET 1.x and 2.0 Application Design 4 April 14th, 2004 02:12 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.