Click here to Skip to main content
15,907,492 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
private void button1_Click(object sender, EventArgs e)
        {
            string bkcode = "";
            string bname = "";
            string publisher = "";
            string author = "";
            string adate = "";
            string price = "";
            string rack = "";
            try
            {
                conn.Open();
                OleDbCommand cmd = new OleDbCommand("select * from Temp where Book_code='"+textBox2.Text+"'");
                OleDbDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    bkcode = rdr[0].ToString();
                    bname = rdr[1].ToString();
                    publisher = rdr[2].ToString();
                    author = rdr[3].ToString();
                    adate = rdr[4].ToString();
                    price = rdr[5].ToString();
                    rack = rdr[6].ToString();
                }
                OleDbCommand cmd1 = new OleDbCommand("insert into BookStock values(@Book_code,@Book_name,@Publisher,@Author,@Arrival_date,@Price,@Rack_no)",conn);
                cmd1.Parameters.AddWithValue("@Book_code", bkcode);
                cmd1.Parameters.AddWithValue("@Book_name", bname);
                cmd1.Parameters.AddWithValue("@Publisher", publisher);
                cmd1.Parameters.AddWithValue("@Author", author);
                cmd1.Parameters.AddWithValue("@Arrival_date", adate);
                cmd1.Parameters.AddWithValue("@Price", price);
                cmd1.Parameters.AddWithValue("@Rack_no", rack);
                cmd1.ExecuteNonQuery();
                conn.Close();
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
                conn.Close();
            }
        }



can anyone tell me how to move data of one table into other table.
I have two table i.e Bookstock and Temp.I am using the above code to move date but i got the given error:Could not find installable ISAM.
Posted
Comments
[no name] 5-May-12 9:12am    
http://social.msdn.microsoft.com/Forums/eu/adodotnetdataproviders/thread/aa2f7e08-4df9-4d6c-b638-d7e533687ab0

1 solution

The problem lies here I guess.......



C#
OleDbCommand cmd = new OleDbCommand("select * from Temp where Book_code='"+textBox2.Text+"'");


Why don't you tell the command on which connection will it run like


C#
OleDbCommand cmd = new OleDbCommand("select * from Temp where Book_code='"+textBox2.Text+"'",con);



Best of luck.....

Hope it helps
 
Share this answer
 
Comments
Member 8233601 5-May-12 9:25am    
i made it but still it not work..
Mantu Singh 5-May-12 10:42am    
pls post the code for both connection strings you use...........
Member 8233601 7-May-12 1:05am    
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Soure=|DataDirectory|/Schooldb.mdb");
Mantu Singh 7-May-12 3:52am    
Try this........
where is one more connection string code......?
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Soure=|DataDirectory|\Schooldb.mdb");

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