We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,612 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

IMPORTING Excel

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

2
Contributors
1
Reply
4 Days
Discussion Span
9 Months Ago
Last Updated
2
Views
ebin
Newbie Poster
1 post since Aug 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

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.

Cameronsmith63
Junior Poster in Training
74 posts since May 2010
Reputation Points: 19
Solved Threads: 4
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0531 seconds using 2.66MB