B
Bajtitou
Guest
Hi,
Please I need somme help here,
This Code Run Well but It Can't Update DataBase..Update.
Private Sub Totaux1()
Try
Using cn As New OleDb.OleDbConnection With
{
.ConnectionString = Builder.ConnectionString
}
Using cmd As New OleDb.OleDbCommand With {.Connection = cn}
cmd.CommandText = "Select Sum (IIf(Clmn1 Is Null, 0,Clmn1)) As Sum1,
Sum (IIf(Colmn2 Is Null, 0,Colmn2)) As Sum2,
Sum (IIf(Clmn3 Is Null,0,Clmn3)) As Sum3,
FROM Table1"
cn.Open()
Dim Rdr As OleDb.OleDbDataReader = cmd.ExecuteReader
If Rdr.HasRows Then
While Rdr.Read
Dim Sum1 As Integer = Rdr.Item("Sum1")
Dim Sum2 As Integer = Rdr.Item("Sum2")
Dim Sum3 As Integer = Rdr.Item("Sum3")
cmd.CommandText = "Update Table2 Set TotalClmn1=@d2,TotalClmn1=@d3,TotalClmn1=@d3,
Where Total=@d1"
cmd.Parameters.AddWithValue("@d1","ToTal1")
cmd.Parameters.AddWithValue("@d2", Rdr.Item("Sum1"))
cmd.Parameters.AddWithValue("@d3", Rdr.Item("Sum2"))
cmd.Parameters.AddWithValue("@d4", Rdr.Item("Sum3"))
cmd.ExecuteNonQuery()
Dgw2.Refresh()
cmd.CommandText = "Update Table3 Set Totaux=@d2 Where ToTal=@d1"
cmd.Parameters.AddWithValue("@d1", "Total1")
cmd.Parameters.AddWithValue("@d2", Rdr.Item("Sum3"))
cmd.ExecuteNonQuery()
Dgw2.Refresh()
End While
If Not Rdr Is Nothing Then
Rdr.Close()
End If
Exit Sub
End If
Rdr.Close()
End Using
End Using
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
So Thank you very Much .
Continue reading...
Please I need somme help here,
This Code Run Well but It Can't Update DataBase..Update.
Private Sub Totaux1()
Try
Using cn As New OleDb.OleDbConnection With
{
.ConnectionString = Builder.ConnectionString
}
Using cmd As New OleDb.OleDbCommand With {.Connection = cn}
cmd.CommandText = "Select Sum (IIf(Clmn1 Is Null, 0,Clmn1)) As Sum1,
Sum (IIf(Colmn2 Is Null, 0,Colmn2)) As Sum2,
Sum (IIf(Clmn3 Is Null,0,Clmn3)) As Sum3,
FROM Table1"
cn.Open()
Dim Rdr As OleDb.OleDbDataReader = cmd.ExecuteReader
If Rdr.HasRows Then
While Rdr.Read
Dim Sum1 As Integer = Rdr.Item("Sum1")
Dim Sum2 As Integer = Rdr.Item("Sum2")
Dim Sum3 As Integer = Rdr.Item("Sum3")
cmd.CommandText = "Update Table2 Set TotalClmn1=@d2,TotalClmn1=@d3,TotalClmn1=@d3,
Where Total=@d1"
cmd.Parameters.AddWithValue("@d1","ToTal1")
cmd.Parameters.AddWithValue("@d2", Rdr.Item("Sum1"))
cmd.Parameters.AddWithValue("@d3", Rdr.Item("Sum2"))
cmd.Parameters.AddWithValue("@d4", Rdr.Item("Sum3"))
cmd.ExecuteNonQuery()
Dgw2.Refresh()
cmd.CommandText = "Update Table3 Set Totaux=@d2 Where ToTal=@d1"
cmd.Parameters.AddWithValue("@d1", "Total1")
cmd.Parameters.AddWithValue("@d2", Rdr.Item("Sum3"))
cmd.ExecuteNonQuery()
Dgw2.Refresh()
End While
If Not Rdr Is Nothing Then
Rdr.Close()
End If
Exit Sub
End If
Rdr.Close()
End Using
End Using
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
So Thank you very Much .
Continue reading...