i want import Excel work sheet into ms acess existing table

      try
            {
                string conn = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + filename + ";" + "Extended Properties=Excel 12.0 Xml;";
                OleDbConnection con = new OleDbConnection(conn);
                OleDbCommand cmd = new OleDbCommand();
                con.Open();
                cmd.CommandText = @"SELECT * INTO [MS Access;Database=" + adb + "].[test] FROM [test$]";
                cmd.Connection = con;
                cmd.ExecuteNonQuery();
                MessageBox.Show("inserted");
                con.Close();
            }
            catch (DbException ex)
            {
                MessageBox.Show("Failed to access database");
                MessageBox.Show(ex.Message);
                return;
            }

but its create new table and insert values?
how i insert existitg existing databases ms access

ok, im not sure what you want, but i'll try. Your question is, you want to insert data into an existing table?

Your SQL command "select into" creates a new table of data, that is not the command that you should be using.

You can write an "INSERT INTO (select * from....)

where your select statement in the brackets would be your subquery, the selection of what you want from the excel file, and inserted into an existing table.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.