arkadaslar bakar mısın nerede hata yapıyorum Hata " oledbexception was unhandled executenonquery"
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace Deneme2
{
public partial class Form1 : Form
{
public OleDbConnection baglanti = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=v2.accdb");
public OleDbCommand komut = new OleDbCommand();
public OleDbDataAdapter adtr = new OleDbDataAdapter();
public DataTable tablo = new DataTable();
public Form1()
{
InitializeComponent();
}
public **** listele()
{
tablo.Clear();
OleDbDataAdapter adtr = new OleDbDataAdapter("select * from [Tablo1]", baglanti);
adtr.Fill(tablo);
dataGridView1.DataSource = tablo;
}
TimeSpan fark;
double farkgun;
**** renklendir()
{
for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
{
fark = Convert.ToDateTime(dataGridView1.Rows.Cells["tarih"].Value.ToString()) - Convert.ToDateTime(DateTime.Now.ToShortDateString());
farkgun = fark.TotalDays;
if (farkgun < 3) dataGridView1.Rows.DefaultCellStyle.BackColor = Color.Blue;
else if (farkgun > 2 && farkgun < 6) dataGridView1.Rows.DefaultCellStyle.BackColor = Color.Yellow;
}
}
private **** button1_Click(object sender, EventArgs e)
{
baglanti.Open();
komut.Connection = baglanti;
komut.CommandText = " INSERT INTO Tablo1(sayac1,sayac2,tarih) VALUES (@sayac1,@sayac2,@tarih) ";
komut.Parameters.AddWithValue("@sayac1", textBox1.Text);
komut.Parameters.AddWithValue("@sayac2", textBox2.Text);
komut.Parameters.AddWithValue("@tarih", dateTimePicker1.Text);
komut.ExecuteNonQuery();
komut.Dispose();
baglanti.Close();
for (int i = 0; i <= this.Controls.Count - 1; i++)
{
if (this.Controls is TextBox)
{
this.Controls.Text = "";
}
}
listele();
renklendir();
MessageBox.Show("Kayıt Edildi");
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace Deneme2
{
public partial class Form1 : Form
{
public OleDbConnection baglanti = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=v2.accdb");
public OleDbCommand komut = new OleDbCommand();
public OleDbDataAdapter adtr = new OleDbDataAdapter();
public DataTable tablo = new DataTable();
public Form1()
{
InitializeComponent();
}
public **** listele()
{
tablo.Clear();
OleDbDataAdapter adtr = new OleDbDataAdapter("select * from [Tablo1]", baglanti);
adtr.Fill(tablo);
dataGridView1.DataSource = tablo;
}
TimeSpan fark;
double farkgun;
**** renklendir()
{
for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
{
fark = Convert.ToDateTime(dataGridView1.Rows.Cells["tarih"].Value.ToString()) - Convert.ToDateTime(DateTime.Now.ToShortDateString());
farkgun = fark.TotalDays;
if (farkgun < 3) dataGridView1.Rows.DefaultCellStyle.BackColor = Color.Blue;
else if (farkgun > 2 && farkgun < 6) dataGridView1.Rows.DefaultCellStyle.BackColor = Color.Yellow;
}
}
private **** button1_Click(object sender, EventArgs e)
{
baglanti.Open();
komut.Connection = baglanti;
komut.CommandText = " INSERT INTO Tablo1(sayac1,sayac2,tarih) VALUES (@sayac1,@sayac2,@tarih) ";
komut.Parameters.AddWithValue("@sayac1", textBox1.Text);
komut.Parameters.AddWithValue("@sayac2", textBox2.Text);
komut.Parameters.AddWithValue("@tarih", dateTimePicker1.Text);
komut.ExecuteNonQuery();
komut.Dispose();
baglanti.Close();
for (int i = 0; i <= this.Controls.Count - 1; i++)
{
if (this.Controls is TextBox)
{
this.Controls.Text = "";
}
}
listele();
renklendir();
MessageBox.Show("Kayıt Edildi");
}
}
}
