Click here to Skip to main content
15,880,608 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I've a pretty simple windows application coded in C# [winforms] using SQL Compact database 3.5 and I'm trying to fetch / read text data values at the first run of the application on each PC.

I've tried to read data from Excel sheet \ Access database \ MySql database \ text files [ON FREE HOSTING PLANS] but they all failed (mostly because all the free hosting websites don't offer remote access to files).

So is there any work around to this issue ? I just want to read data from files , nothing more.
Posted
Comments
Sergey Alexandrovich Kryukov 10-Apr-15 17:36pm    
It all depends on how you host the files. Before you explain it all, the question makes little sense. What hosting? Is it Web hosting? If so, you can simply serve up the file using HTTP, but then — what's your server-side technology? And why not just using HTML anchors?
—SA
Sherif Kamel 10-Apr-15 19:11pm    
Well , you guided me to the way. I've searched for the HTTP requests and came up with a code that enabled the connection to the text file normally. Thanks a lot.
But what about excel file sheet ? can I read it's data the same way ?
Sergey Alexandrovich Kryukov 10-Apr-15 19:29pm    
You are welcome.
Please see Solution 1.
—SA

1 solution

Sherif Kamel wrote:

Well , you guided me to the way. I've searched for the HTTP requests and came up with a code that enabled the connection to the text file normally. Thanks a lot.
But what about excel file sheet ? can I read it's data the same way?
Not quite the same way, but…

I would advise to use Microsoft Open XML SDK. I hope your files are not of obsolete and proprietary .xls format, but in .xlsx format based on the international ISO/IEC 29500:2008 standard and publicly available ECMA-376 standard:
http://en.wikipedia.org/wiki/Office_Open_XML.

Please see my past answers referenced in this one: How to add microsoft excel 15.0 object library from Add Reference in MS Visual Studio 2010.

See also this CodeProject article: Creating basic Excel workbook with Open XML.

Sorry, it is devoted to the creation of a workbook, but it can give you the general idea.

[EDIT]

Note that on the server side you can do different things. You can host the files and simply present them using HTML anchors. But you can compose the files on the fly out of some data and provide them on request. In case of ASP.NET, you can do it using the same very Open XML SDK mentioned above (and, in this case, the CodeProject article I referenced would be the very it).

The key here is to set correct ContentType of you HttpResponse. These types are strings supported by IANA:
http://www.iana.org/assignments/media-types/media-types.xhtml,
http://www.iana.org/assignments/media-types/media-types.xhtml#application.

See also: http://en.wikipedia.org/wiki/Internet_Assigned_Numbers_Authority.

—SA
 
Share this answer
 
v4
Comments
Sherif Kamel 10-Apr-15 19:50pm    
I didn't start making any excel files yet so I think I'll adapt to your guide. I'm pretty sure I'll come up with pretty good ideas from these great topics. Thanks for the help :)
Sergey Alexandrovich Kryukov 10-Apr-15 20:03pm    
You are very welcome.
Good luck, call again.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900