aşağıdaki kodda şu hata iletisini alıyotum:
Error CS7036 There is no argument given that corresponds to the required formal parameter 'cell' of 'Form1.InsertRow(OleDbConnection, string)' test1 c:\users\asus\documents\visual studio 2017\Projects\test1\test1\Form1.cs 103 Active
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace test1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
datagrid1load();
datagrid2load();
}
OleDbConnection con_invoice;
OleDbDataAdapter da_invoice;
DataSet ds_invoice;
public void datagrid1load()
{
string patch = Application.StartupPath + "\\data.mdb";
con_invoice = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source =" + patch);
da_invoice = new OleDbDataAdapter("SElect *from invoice", con_invoice);
ds_invoice = new DataSet();
con_invoice.Open();
da_invoice.Fill(ds_invoice, "invoice");
datagrid1.DataSource = ds_invoice.Tables["invoice"];
con_invoice.Close();
}
OleDbConnection con_period;
OleDbDataAdapter da_period;
DataSet ds_period;
public void datagrid2load()
{
string patch = Application.StartupPath + "\\data.mdb";
con_period = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source =" + patch);
da_period = new OleDbDataAdapter("SElect *from period", con_period);
ds_period = new DataSet();
con_period.Open();
da_period.Fill(ds_period, "period");
datagrid2.DataSource = ds_period.Tables["period"];
con_period.Close();
}
void InsertRow(OleDbConnection conn, string cell)
{
string patch = Application.StartupPath + "\\data.mdb";
DateTime month;
if (DateTime.TryParseExact(cell, "MM.yyyy", null, DateTimeStyles.None, out month))
{
InsertMonth(month.AddMonths(-1));
InsertMonth(month);
}
}
void InsertMonth(DateTime month)
{
string patch = Application.StartupPath + "\\data.mdb";
using (var conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + patch))
using (var cmd = conn.CreateCommand())
{
cmd.Connection.Open();
cmd.CommandText = "insert into period (a) values (?)";
cmd.Parameters.AddWithValue("?", month.ToString("MM/yyyy"));
cmd.ExecuteNonQuery();
}
}
private void addemptyperiodbutton_Click(object sender, EventArgs e)
{
for (int i = 1; i <= 1000 && (datagrid1.RowCount > i); i++)
{
InsertRow(datagrid1.Rows.Cells[1].Value.ToString()); // teka a error message "cell"
}
perioddublicateclean();
datagrid2load();
}
int periodclean1, periodclean2;
private void perioddublicateclean()
{
string patch = Application.StartupPath + "\\data.mdb";
try
{
OleDbConnection con = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0; Data Source=" + patch);
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter("select * from period", con);
con.Open();
da.Fill(ds, "period");
for (int i = 0; i < ds.Tables["period"].Rows.Count; i++)
{
DataRow row = ds.Tables["period"].Rows;
periodclean2++;
for (int j = periodclean2; j < ds.Tables["period"].Rows.Count; j++)
{
DataRow row2 = ds.Tables["period"].Rows[j];
if (row.ItemArray.GetValue(1).ToString() == row2.ItemArray.GetValue(1).ToString())
{
if (row.ItemArray.GetValue(3).ToString() == row2.ItemArray.GetValue(3).ToString())
{
periodclean1 = int.Parse(row2.ItemArray.GetValue(0).ToString());
periodcleanrun(periodclean1);
}
}
}
}
}
catch
{ }
}
private void periodcleanrun(int num)
{
string patch = Application.StartupPath + "\\data.mdb";
OleDbConnection con = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0; Data Source=" + patch);
con.Open();
OleDbCommand c = new OleDbCommand("Delete from period where ID =?", con);
c.Parameters.AddWithValue("ID", num);
c.ExecuteNonQuery();
con.Close();
}
}
}