Click here to Skip to main content
14,385,176 members
Rate this:
Please Sign up or sign in to vote.
Greetings,

Can anyone have sample application for Import and Export Excel file data to SQLCE database table.
I am using dot net 2008 to create an application which can work on Windows CE devices.
I created the application with database as MyData.SDF. inside i created Product table with Itemcode,Description,Qty,Expirydate and price.
Now i have an excel file with data such as Itemcode,Description,Qty,Expirydate and price.The excel file is copied to my Windows CE device application path.
While i am trying the read the Excel file from the device application path, it gives me error. File not found. Can some one suggest me any other methods to complete these import and export process. your help will be highly appreciated.
Posted
Updated 7-Nov-19 23:31pm
v2
Comments
digimanus 1-Jun-15 6:50am
   
- Have you checked the file is in the path you say it is? (DEBUG your app!)
- Have you googled? Example-result to watch: https://exceldatareader.codeplex.com/
Arun Ashok 1-Jun-15 7:29am
   
Thanks for the reply. But i debugged my program and still the same.
johannesnestler 1-Jun-15 9:47am
   
do you use a library to read and write(!) "Excel" files on CE? What you mean with "Excel"- files? xls? When I was programming for Windows CE 5/6 it wasn't possible to do any office-automation on CE Clients without expensive 3rd party components... just curiouse how you handle that?
To your Problem: "file not found" is quite obviouse - what other "methods" would you expect (- we don't even know your current "method") to work. If you can't find your file, nothing will help... So what do you mean "debugged and still the same"? Debug means - go through your code step by step and have a look if everything meets your expectations. Is the path correct (you know how the paths work on WinCE, do you?), is the file there, and so on...
Arun Ashok 21-Jun-15 6:26am
   
Hai johannesnestler,
I got your point.
"Windows CE 5/6 it wasn't possible to do any office-automation on CE Clients without expensive 3rd party components "

So now i am trying to read from a text file. but the error is still same. Please refer the below points.

1. i am building and deployed the solution to the emulator, not on actual device. 2. while i tried to access the file it gives me the error-
The file was copied to my debug folder and the same path is specified inside in the code.
path i given inside the code is "System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\Items.txt"
what will be the problem. is it because i am running from an emulator. if it so then what will be the path. I have the file copied to my debug folder and the error message shows "Could not find file '\Program Files\SmartSys\Items.txt'."

3. i am using a sql CE database and the path i given is some what same. please see the code below. it doesnt have any problem for accessing it.
conn.ConnectionString = "Data Source=" + System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\MyData.sdf;Persist Security Info=False;";

conn.Open();
SqlCeCommand command = conn.CreateCommand();
Rate this:
Please Sign up or sign in to vote.

Solution 1

Hi ,
First of all, i want to thank you for all the valuable comments and replies.
Suddenly i realize that the problem is not because of the way, but it is because of my sheer negligence. I delete the entire coding and start fresh. This time, i made it. The problem is of the file path is solved by adding the same file in my project and given "Copy to" permission to its properties.
Running from an emulator need the file to be added in the project.
   
v2
Rate this:
Please Sign up or sign in to vote.

Solution 2

Dear friends,
I will give you a very simple solution which monthly data updations for 10 years.

Export data for Excel to SDF 3.5

1. Prepare Excel data compatible with SDF table field data type
2. Just open Visual Studio what you have
3. Select SERVER EXPLORER
and choose data connection
and select the exact SDF database
and select the table you wanted to upload data
and right-click and choose SHOW TABLE DATA
and goto last record then you can see an empty record space starting with an "*"
Click on it then you can see a fade color will appear entire line.
Press ALT+TAB to move to excel highlight the data you want to export
Again press ALT+TAB and in the SDF OPEN TABLE select the empty record
which highlighted before. Then press ^v for paste
HERE THIS WAY EXPORT AND IMPORT WILL ACCOMPLISH BY COPY AND PASTE BETWEEN EXCEL AND SDF



try it and commend to me (site back and relax your data will be safe)
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100