private void btn_actual_insert_Click(object sender, EventArgs e) { if (lb_actual_sheets.Text != "") { string Warning = ""; int rows; if (int.TryParse(tb_actual_end.Text, out rows)) { //начать загрузку if (tb_actual_first.Text == "") tb_actual_first.Text = "1"; _range = "A" + (Convert.ToInt32(tb_actual_first.Text) - 1).ToString() + ":H" + tb_actual_end.Text; OdbcConnection cn = new OdbcConnection(); cn.ConnectionString = string.Format(@"Driver={{Microsoft Excel Driver (*.xls)}};DBQ={0};ReadOnly=0;", lb_actual_file.Text); string strCom = "select * from [" + _sheet + "$" + _range + "]"; cn.Open(); OdbcCommand comm_mon = new OdbcCommand(strCom, cn); OdbcDataAdapter da = new OdbcDataAdapter(); da.SelectCommand = comm_mon; System.Data.DataTable dt = new System.Data.DataTable(); da.Fill(dt); DataSaver ds = new DataSaver(login_, password_); Warning = ds.SaveActualPayment(dt, Convert.ToInt32(tb_actual_first.Text)); ActualPaymentsFill(); if (Warning != "") MessageBox.Show(Warning); } else { MessageBox.Show("Укажите количество строк"); } } }