0

Hello I'm using OleDB and this code is getting an error of no value given for one or more parameters even though im only updating 1 cell and giving 1 value does anyone know why? Also, I have similar code as this but the other one is working while this one is not

    public void excelUpdateNPP()
    {
        //excelConnectionStringRD = "Provider=Microsoft.ACE.OLEDB.12.0;" +
                    //"Data Source=" + RDloc + ";" +
                    //"Extended Properties=Excel 12.0";
        //xlConnRD = new OleDbConnection(excelConnectionStringRD);
        //xlCmdRD = xlConnRD.CreateCommand();
        int col_product = dataGridViewForm1.Columns["New Product Program"].Index;
        int npp_col = dataGridViewForm1.Columns["NPI Phase"].Index + 2;
        string npp_string = ExcelColumnFromNumber(npp_col);
        try
        {

            foreach (DataGridViewRow row in dataGridViewForm1.Rows)
            {
                xlConnRD.Open();
                if (row.Cells[col_product].Value.ToString().Equals(product_name)) ;
                {

                    int cellrow = (row.Index + bigBusinessRow + 1);

                    xlCmdRD.CommandText = "UPDATE [Sheet$" + npp_string + cellrow.ToString() + ":" + npp_string + cellrow.ToString() + "] SET F1 = '"  + cbNPI.Text + "'";
                    xlCmdRD.ExecuteNonQuery();

                }
                xlConnRD.Close();
            }
        }
        catch (Exception err)
        {
            MessageBox.Show(err.Message);
        }
    }
Grant Winney
  • 63,310
  • 12
  • 110
  • 157

0 Answers0