Click here to Skip to main content
15,667,014 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
in our project, i want to copy a table from one access database to another
i'm using this code
query="SELECT * INTO tablename FROM tablename";
but it is only copy the structure and its value, it is not copying any extended properties means there are checkboxes as field value but instead of checkboxes it is taken value as -1 or 0.
so plz tell me the solution..
Updated 10-May-10 21:06pm

This is the way I do it:

SELECT * INTO NewTable FROM OldTable

I don't know why have ampersands in your sql, nor why you're using IN.
Share this answer
if the problem is 1 Or 0 just change the properties of that filed to true/false or anything you want
Share this answer
you can also use SQLBULKCOPY for this with help of given code, but first u have to create both the tables i.e. source table and destination table
//setting the connection string
string connection = "Data Source=.;Initial Catalog=master;Integrated Security=True";

            SqlConnection myconnect = new SqlConnection(connection);
            myconnect.Open(); //open the connection
            SqlCommand cmd = new SqlCommand("select * from sourcetable", myconnect);
            SqlDataReader dr = cmd.ExecuteReader();
//new connection specification
            SqlConnection con = new SqlConnection(connection);
            SqlBulkCopy bulk = new SqlBulkCopy(con);
//name of the destination table where u wana copy ur data
            bulk.DestinationTableName = "desti"; 
            catch (Exception ex)
                MessageBox.Show("Some error");

            MessageBox.Show("Record Copied");

Do Rate my answer once you find it useful

Thanks & Regards
Radix :)
Share this answer

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