nightwolf (Normal User)
Pro
Messaggi: 149
Iscritto: 14/09/2010
|
Questo topic è stato chiuso dal moderatore ormai tutti credo che conoscete il mio problema è l'aggiornamento del database collegato ad un datagrid situato su un form diverso da dove viene l'aggiornamento:posto il codice(speriamo):
[Public Class Giornali
Private Sub Giornali_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: questa riga di codice carica i dati nella tabella 'EdicolaDataSet1.Riviste'. È possibile spostarla o rimuoverla se necessario.
Me.RivisteTableAdapter.Fill(Me.EdicolaDataSet1.Riviste)
Me.DataGridView1.DataSource = Me.EdicolaDataSet1.Riviste
DataGridView1.ReadOnly = True
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer = Me.DataGridView1.CurrentRow.Index
Inserimento_Giornali.TextBox1.Text = Me.DataGridView1.Rows(i).Cells(0).Value
Inserimento_Giornali.TextBox2.Text = Me.DataGridView1.Rows(i).Cells(1).Value
Inserimento_Giornali.ComboBox1.Text = Me.DataGridView1.Rows(i).Cells(2).Value
Inserimento_Giornali.TextBox3.Text = Me.DataGridView1.Rows(i).Cells(3).Value
Inserimento_Giornali.TextBox5.Text = Me.DataGridView1.Rows(i).Cells(4).Value
Inserimento_Giornali.ComboBox2.Text = Me.DataGridView1.Rows(i).Cells(5).Value
Inserimento_Giornali.TextBox7.Text = Me.DataGridView1.Rows(i).Cells(6).Value
Inserimento_Giornali.Show()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Inserimento_Giornali.Show()
End Sub
End Class]
form2:
[Public Class Inserimento_Giornali
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
Private Sub btnSalva_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSalva.Click
Dim i As Integer = Giornali.DataGridView1.CurrentRow.Index
If TextBox1.Text <> Giornali.DataGridView1.Rows(i).Cells(0).Value Then
Giornali.DataGridView1.Rows(i).Cells(0).Value = TextBox1.Text
ElseIf TextBox2.Text <> Giornali.DataGridView1.Rows(i).Cells(1).Value Then
Giornali.DataGridView1.Rows(i).Cells(1).Value = TextBox2.Text
ElseIf TextBox3.Text <> Giornali.DataGridView1.Rows(i).Cells(3).Value Then
Giornali.DataGridView1.Rows(i).Cells(3).Value = TextBox3.Text
ElseIf ComboBox1.Text <> Giornali.DataGridView1.Rows(i).Cells(2).Value Then
Giornali.DataGridView1.Rows(i).Cells(2).Value = ComboBox1.Text
ElseIf TextBox5.Text <> Giornali.DataGridView1.Rows(i).Cells(4).Value Then
Giornali.DataGridView1.Rows(i).Cells(4).Value = TextBox5.Text
ElseIf ComboBox2.Text <> Giornali.DataGridView1.Rows(i).Cells(5).Value Then
Giornali.DataGridView1.Rows(i).Cells(5).Value = ComboBox2.Text
ElseIf TextBox7.Text <> Giornali.DataGridView1.Rows(i).Cells(6).Value Then
Giornali.DataGridView1.Rows(i).Cells(6).Value = TextBox7.Text
End If
Giornali.RivisteTableAdapter.update(Giornali.EdicolaDataSet1.Riviste)
Me.Close()
End Sub
End Class]
ps:speriamo che vadi bene
|