string strcnn = "کانکشن استرینگ"; OleDbConnection connection;
OleDbCommand command;
private void button1_Click(object sender, EventArgs e)
{
connection = new OleDbConnection(strcnn);
foreach (DataGridViewRow row in dataGridView1.Rows)
{
var n = row.Cells[0].Value.ToString();
command = new OleDbCommand();
command.CommandText = "INSERT INTO نام جدول نام فیلد VALUES'" + n + "'";
command.Connection = connection;
try
{
connection.Open();
command.ExecuteNonQuery();
connection.Close();
}
catch (OleDbException ex) { MessageBox.Show(ex.Message); }
}
ViewRecords();
}
private void ViewRecords()
{
connection = new OleDbConnection(strcnn);
command = new OleDbCommand("SELECT * FROM نام جدول", connection);
OleDbDataAdapter adapter = new OleDbDataAdapter(command);
DataSet dataSet = new DataSet();
BindingSource source = new BindingSource();
adapter.Fill(dataSet); source.DataSource = dataSet.Tables[0];
dataGridView1.DataSource = source;
}
طریقه ذخیره اطلاعات در دیتابیس اکسس در انجمن زیاد وجود دارد جستجو کنید