Click here to Skip to main content
13,549,174 members
Rate this:
Please Sign up or sign in to vote.
See more:
I'm exporting table from access to system and importing the table.The table is getting saved but its not readable and not getting imported also.I have follow the below code,
if (radioButton7.Checked == true)
da = new OleDbCommand(Delete from xxx", con);
foreach (DataRow dr in dt.Rows)
OleDbCommand da1 = new OleDbCommand("insert into xxx values("+dr[0].ToString()+",'"+dr[1].ToString()+"','"+dr[2].ToString()+"','"+dr[3].ToString()+"',"+dr[4].ToString()+","+dr[5].ToString()+",'"+dr[6].ToString()+"','"+dr[7].ToString()+"',"+dr[8].ToString()+",'"+dr[9].ToString()+"','"+dr[10].ToString()+"',"+dr[11].ToString()+",'"+dr[12].ToString()+"','"+dr[13].ToString()+"','"+dr[14].ToString()+"','"+dr[15].ToString()+"',"+dr[16].ToString()+",'"+dr[17].ToString()+"')", con);
Posted 23-Jan-13 20:35pm
Daniele-Rota-Nodari 24-Jan-13 2:55am
You wrote that the exported file is not readable, but the sample code you provided shows only import function.
You should add more details about export process or about importing errors or imported results.
Balamurugan1989 24-Jan-13 3:05am
Ya i'm exporting and importing 3 tables first 2 tables process working fine it has been exported and imported successfully.3rd table is getting saved in system but it cant able to edit the file showing as readable.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

There are a couple of things that you should try:
1) Do not concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Use Parametrized queries instead. This may help with your problem, depending on your data content.
2) Try Disposing of your OleDbCommands when you have finished with them - they are a limited resource, and should not be left to the Garbage collector to get rid of them.
3) Look at your output file, and make sure that it isn't in a later format than whatever you are trying to read it from. Try opening it in your code, selecting a few items, and closing it again. Is the file "still readable"?

If none of this helps, we would need to know more about what you are actually connecting to - OleDb can connect to a huge variety of sources, and you don't tell us which.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

For Exporting and Importing Excel File we need to follow the below steps
1.We need to add saveFileDialog1 and openFileDialog1 from toolbox.
2.In saveFileDialog1->Right Click->Properties.
3.In Properties Filter option will be available.
4..In Filter Option we need to write the below line,
5.Now if we are exporting the file it will be saved in Excel method.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.180515.1 | Last Updated 30 Jan 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

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