Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Kako se promene u DataGridView prosledjuju u bazu?

[es] :: .NET :: Kako se promene u DataGridView prosledjuju u bazu?

[ Pregleda: 3055 | Odgovora: 4 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

L a d y

Član broj: 101977
Poruke: 53
80.74.160.*



Profil

icon Kako se promene u DataGridView prosledjuju u bazu?30.01.2007. u 10:06 - pre 209 meseci
Kako se nakon promena u DataGridView vrsi update baze?
 
Odgovor na temu

ads

Član broj: 127796
Poruke: 13
*.informatika.com.



Profil

icon Re: Kako se promene u DataGridView prosledjuju u bazu?30.01.2007. u 10:11 - pre 209 meseci
Imas super primer ovde
 
Odgovor na temu

L a d y

Član broj: 101977
Poruke: 53
80.74.160.*



Profil

icon Re: Kako se promene u DataGridView prosledjuju u bazu?30.01.2007. u 17:09 - pre 209 meseci
Da li se update moze izvrsiti kroz pogled (view), ili samo kroz tabelu?
 
Odgovor na temu

BezPanike

Član broj: 128571
Poruke: 74



+2 Profil

icon Re: Kako se promene u DataGridView prosledjuju u bazu?30.01.2007. u 20:08 - pre 209 meseci
Može UPDATE i za view.
 
Odgovor na temu

L a d y

Član broj: 101977
Poruke: 53
80.74.160.*



Profil

icon Re: Kako se promene u DataGridView prosledjuju u bazu?30.01.2007. u 21:43 - pre 209 meseci
Primer je dobar kod izmene sadrzaja tabele. Ako se isti kod upotrebi za izmenu sadrzaja preko pogleda, javlja se Error 7: 'prog.pDataSetTableAdapters.NTableAdapter' does not contain a definition for 'Update'. U cemu je poenta?

[quote]public partial class MainForm: Form {
public MainForm() {
InitializeComponent();
}

private void MainForm_Load(
object sender, EventArgs e)
{
this.regionTableAdapter.Fill(
this.northwindDataSet.Region);
// resize the column once, but allow the
// users to change it.
this.regionDataGridView.AutoResizeColumns(
DataGridViewAutoSizeColumnsMode.AllCells);
}

//tracks for PositionChanged event last row
private DataRow LastDataRow = null;

/// <SUMMARY>
/// Checks if there is a row with changes and
/// writes it to the database
/// </SUMMARY>
private void UpdateRowToDatabase() {
if (LastDataRow!=null) {
if (LastDataRow.RowState==
DataRowState.Modified) {
regionTableAdapter.Update(LastDataRow);
}
}
}

private void regionBindingSource_PositionChanged(
object sender, EventArgs e)
{
// if the user moves to a new row, check if the
// last row was changed
BindingSource thisBindingSource =
(BindingSource)sender;
DataRow ThisDataRow=
((DataRowView)thisBindingSource.Current).Row;
if (ThisDataRow==LastDataRow) {
// we need to avoid to write a datarow to the
// database when it is still processed. Otherwise
// we get a problem with the event handling of
//the DataTable.
throw new ApplicationException("It seems the" +
" PositionChanged event was fired twice for" +
" the same row");
}

UpdateRowToDatabase();
// track the current row for next
// PositionChanged event
LastDataRow = ThisDataRow;
}

private void MainForm_FormClosed(
object sender, FormClosedEventArgs e)
{
UpdateRowToDatabase();
}
}

 
Odgovor na temu

[es] :: .NET :: Kako se promene u DataGridView prosledjuju u bazu?

[ Pregleda: 3055 | Odgovora: 4 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.