0

Here's my problem: I have an excel file which i run on a certain row. I am trying to compare the datarow value with a string value. if it equals, i want to add the value of a close cell to access table.

I know only how to copy paste.

     private void button1_Click(object sender, EventArgs e)
         {
            database11DataSet.tblContacts.NewRow();
            foreach (DataRow r in dsContacts.Tables[0].Rows)
              {
                 string a = "123";
                 DataRow dr = database11DataSet.tblContacts.NewRow();


                 if (dr[0] == a) ///How to compare??
                 {
                   ///////
                 }
                  //// I want to write the value of a close cell to the access database.
                database11DataSet.tblContacts.Rows.Add(dr);
           }

                tblContactsTableAdapter.Update(database11DataSet);
        }

Im sorry if i am not clear. I can explain again if needed. thanks for help.

4

1 回答 1

1

如果 dr[0] 中的值是字符串,您可以尝试:

dr[0].ToString().Equals(a)

于 2013-09-25T00:44:17.127 回答