[code=vbnet]Imports System.XML
Public Class Form1
Inherits System.Windows. Forms.Form
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
transactions = New Transaction() {}
GCC.Open()
End Sub
Private Sub btnLoad_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles btnLoad.Click
Dim action As String
Dim country As String
Dim month As Integer
Dim year As Integer
Dim amount As Double
Dim document As XmlDocument
Dim reader As XmlNodeReader
Dim ofd As OpenFileDialog = New OpenFileDialog
Dim result As DialogResult = ofd.ShowDialog
If (result = DialogResult.Ca ncel) Then
Return
End If
document = New XmlDocument
document.Load(o fd.FileName)
reader = New XmlNodeReader(d ocument)
reader.Read() 'skip root node
While reader.Read()
If (reader.Name = "transactio n") Then
reader.Read()
action = reader.ReadElem entString
country = reader.ReadElem entString
month = reader.ReadElem entString
year = reader.ReadElem entString
amount = reader.ReadElem entString
ReDim Preserve transactions(tr ansactions.Leng th)
transactions(tr ansactions.Leng th - 1) = New Transaction(act ion, country, month, year, amount)
End If
End While
Try
Dim t As Transaction
For Each t In Me.transactions
If t.getAction = "insert" Then
LNGAdapter.Inse rtCommand.Comma ndText = _
"INSERT INTO LNGproduction (fldCountry, fldMonth, fldYear, fldAmount ) VALUES('" & _
t.getCountry & "', " & t.getMonth & ", " & t.getYear & ", " & t.getAmount & ")"
LNGAdapter.Inse rtCommand.Execu teNonQuery()
ElseIf (t.getAction = "update") Then
LNGAdapter.Upda teCommand.Comma ndText = _
"UPDATE LNGproduction SET fldAmount=" & t.getAmount & "WHERE fldCountry=" & " AND" & t.getCountry & "' AND fldMonth=" & t.getMonth & _
"AND fldYear=" & t.getYear
LNGAdapter.Upda teCommand.Execu teNonQuery()
ElseIf (t.getAction = "delete") Then
LNGAdapter.Dele teCommand.Comma ndText = _
"DELETE FROM LNGproduction WHERE fldCountry=" & " '" & t.getCountry & "' AND fldMonth=" & t.getMonth & _
" AND fldYear=" & t.getYear
LNGAdapter.Dele teCommand.Execu teNonQuery()
End If
Next
Catch oleDbExceptionP arameter As System.Data.Ole Db.OleDbExcepti on
Console.WriteLi ne(oleDbExcepti onParameter)
End Try
End Sub
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles Button1.Click
LNGAdapter.Sele ctCommand.Comma ndText = TextBox1.Text
LngDataSet.Clea r()
LNGAdapter.Fill (LngDataSet, "LNGproduction" )
DataGrid1.SetDa taBinding(LngDa taSet, "LNGproduction" )
End Sub
End Class[/code]
The update not working with me i don't know why
Public Class Form1
Inherits System.Windows. Forms.Form
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
transactions = New Transaction() {}
GCC.Open()
End Sub
Private Sub btnLoad_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles btnLoad.Click
Dim action As String
Dim country As String
Dim month As Integer
Dim year As Integer
Dim amount As Double
Dim document As XmlDocument
Dim reader As XmlNodeReader
Dim ofd As OpenFileDialog = New OpenFileDialog
Dim result As DialogResult = ofd.ShowDialog
If (result = DialogResult.Ca ncel) Then
Return
End If
document = New XmlDocument
document.Load(o fd.FileName)
reader = New XmlNodeReader(d ocument)
reader.Read() 'skip root node
While reader.Read()
If (reader.Name = "transactio n") Then
reader.Read()
action = reader.ReadElem entString
country = reader.ReadElem entString
month = reader.ReadElem entString
year = reader.ReadElem entString
amount = reader.ReadElem entString
ReDim Preserve transactions(tr ansactions.Leng th)
transactions(tr ansactions.Leng th - 1) = New Transaction(act ion, country, month, year, amount)
End If
End While
Try
Dim t As Transaction
For Each t In Me.transactions
If t.getAction = "insert" Then
LNGAdapter.Inse rtCommand.Comma ndText = _
"INSERT INTO LNGproduction (fldCountry, fldMonth, fldYear, fldAmount ) VALUES('" & _
t.getCountry & "', " & t.getMonth & ", " & t.getYear & ", " & t.getAmount & ")"
LNGAdapter.Inse rtCommand.Execu teNonQuery()
ElseIf (t.getAction = "update") Then
LNGAdapter.Upda teCommand.Comma ndText = _
"UPDATE LNGproduction SET fldAmount=" & t.getAmount & "WHERE fldCountry=" & " AND" & t.getCountry & "' AND fldMonth=" & t.getMonth & _
"AND fldYear=" & t.getYear
LNGAdapter.Upda teCommand.Execu teNonQuery()
ElseIf (t.getAction = "delete") Then
LNGAdapter.Dele teCommand.Comma ndText = _
"DELETE FROM LNGproduction WHERE fldCountry=" & " '" & t.getCountry & "' AND fldMonth=" & t.getMonth & _
" AND fldYear=" & t.getYear
LNGAdapter.Dele teCommand.Execu teNonQuery()
End If
Next
Catch oleDbExceptionP arameter As System.Data.Ole Db.OleDbExcepti on
Console.WriteLi ne(oleDbExcepti onParameter)
End Try
End Sub
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles Button1.Click
LNGAdapter.Sele ctCommand.Comma ndText = TextBox1.Text
LngDataSet.Clea r()
LNGAdapter.Fill (LngDataSet, "LNGproduction" )
DataGrid1.SetDa taBinding(LngDa taSet, "LNGproduction" )
End Sub
End Class[/code]
The update not working with me i don't know why
Comment