PDA

View Full Version : سوال: مشكل اتصال بانك اطاعاتي اكسس



pooyan3000
دوشنبه 28 اردیبهشت 1388, 18:24 عصر
لطفاً نحوه ي اتصال C# را با بانك اطلاعاتي اكسس با استفاده از WIZARD و دستوران ADDNEW, DELETE UPDATE را توضيح دهيد.

hsmfaridmehr
دوشنبه 28 اردیبهشت 1388, 19:16 عصر
اینو من توی یکی از برنامه های خودم استفاده کردم

اضافه کردن



TimerDBDataSet.DeviceRow row = timerDBDataSet.Device.NewDeviceRow();
try
{
row.DeviceName = combDeviceName.Text;
row.Operation = combOperation.Text;
row.Date = combDate.Text;
row.Time = dateTimePicker2.Value;
timerDBDataSet.Device.AddDeviceRow(row);
deviceTableAdapter.Update(row);
}
catch
{
MessageBox.Show("Unable to add a new operation.", this.Text, MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
finally
{
row = null;
}


حذف کردن



TimerDBDataSet.DeviceRow row = timerDBDataSet.Device.FindByTimerID(
int.Parse(dgv.CurrentRow.Cells["TimerID"].Value.ToString()));
try
{
row.Delete();
deviceTableAdapter.Update(row);
}
catch
{
MessageBox.Show("Unable to delete an operation.", this.Text, MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
finally
{
row = null;
}


بروز رسانی



try
{
TimerDBDataSet.DeviceRow row = (TimerDBDataSet.DeviceRow)timerDBDataSet.Device.Fi ndByTimerID(
int.Parse(dgv.CurrentRow.Cells["DeviceID"].Value.ToString));
row.BeginEdit();
row.DeviceName = combDeviceName.Text;
row.Operation = combOperation.Text;
row.Date = combDate.Text;
row.Time = dateTimePicker2.Value;
row.EndEdit();
deviceTableAdapter.Update(row);
}
catch
{
MessageBox.Show("Unable to update!", this.Text);
}