Results 1 to 9 of 9

Thread: [RESOLVED] Insert problem

Threaded View

  1. #1

    Thread Starter
    Fanatic Member popskie's Avatar
    Join Date
    Jul 2005
    Location
    In my chair
    Posts
    666

    Resolved [RESOLVED] Insert problem

    HI,

    I have a problem during inserting my new record but if I change to select statement. I can display the datareader value. Do you have any idea?

    Code:
            string contring;
    
            private void Form1_Load(object sender, EventArgs e)
            {
                contring = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Book1.xls;Extended Properties=""Excel 8.0;HDR=YES;IMEX=1""";		
            }
    
            private void button2_Click(object sender, EventArgs e)
            {            
                DbProviderFactory dpF = DbProviderFactories.GetFactory("System.Data.OleDb");
                {
                    using (DbConnection dbCon= dpF.CreateConnection())
                    {
                        dbCon.ConnectionString = contring;
                        DbCommand dbCom = dbCon.CreateCommand();                    
    
                        //dbCom.CommandText = "select * from [sheet1$]";
                        dbCom.CommandText = "insert into[sheet1$](first,second)values(\"unse\",\"unse\")";
                        dbCon.Open();
                        DbDataReader dreader = dbCom.ExecuteReader();
    //                    while (dreader.Read())
       //                 {
          //                  MessageBox.Show(dreader["first"].ToString());
             //           }            
    
    
                        dbCon.Close();
                    }

    Thanks,
    Popskie

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width