- Imports System.XML
-
-
Public Class Form1
-
Inherits System.Windows.Forms.Form
-
-
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
-
transactions = New Transaction() {}
-
GCC.Open()
-
End Sub
-
-
Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) 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.Cancel) Then
-
Return
-
End If
-
-
document = New XmlDocument
-
document.Load(ofd.FileName)
-
-
reader = New XmlNodeReader(document)
-
-
reader.Read() 'skip root node
-
While reader.Read()
-
If (reader.Name = "transaction") Then
-
reader.Read()
-
action = reader.ReadElementString
-
country = reader.ReadElementString
-
month = reader.ReadElementString
-
year = reader.ReadElementString
-
amount = reader.ReadElementString
-
ReDim Preserve transactions(transactions.Length)
-
transactions(transactions.Length - 1) = New Transaction(action, 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.InsertCommand.CommandText = _
-
"INSERT INTO LNGproduction (fldCountry, fldMonth, fldYear, fldAmount ) VALUES('" & _
-
t.getCountry & "', " & t.getMonth & ", " & t.getYear & ", " & t.getAmount & ")"
-
LNGAdapter.InsertCommand.ExecuteNonQuery()
-
-
ElseIf (t.getAction = "update") Then
-
LNGAdapter.UpdateCommand.CommandText = _
-
"UPDATE LNGproduction SET fldAmount=" & t.getAmount & "WHERE fldCountry=" & " AND" & t.getCountry & "' AND fldMonth=" & t.getMonth & _
-
"AND fldYear=" & t.getYear
-
LNGAdapter.UpdateCommand.ExecuteNonQuery()
-
-
-
ElseIf (t.getAction = "delete") Then
-
LNGAdapter.DeleteCommand.CommandText = _
-
"DELETE FROM LNGproduction WHERE fldCountry=" & " '" & t.getCountry & "' AND fldMonth=" & t.getMonth & _
-
" AND fldYear=" & t.getYear
-
LNGAdapter.DeleteCommand.ExecuteNonQuery()
-
-
End If
-
Next
-
-
Catch oleDbExceptionParameter As System.Data.OleDb.OleDbException
-
Console.WriteLine(oleDbExceptionParameter)
-
-
End Try
-
-
End Sub
-
-
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
-
-
LNGAdapter.SelectCommand.CommandText = TextBox1.Text
-
LngDataSet.Clear()
-
LNGAdapter.Fill(LngDataSet, "LNGproduction")
-
DataGrid1.SetDataBinding(LngDataSet, "LNGproduction")
-
-
End Sub
-
-
End Class
The update not working with me i don't know why 5 1361
can you explain please what does this line of code means -
"UPDATE LNGproduction SET fldAmount=" & t.getAmount & "WHERE fldCountry=" & " AND" & t.getCountry & "' AND fldMonth=" & t.getMonth & _
-
"AND fldYear=" & t.getYear
-
What is the value for fldCountry ?
can you explain please what does this line of code means -
"UPDATE LNGproduction SET fldAmount=" & t.getAmount & "WHERE fldCountry=" & " AND" & t.getCountry & "' AND fldMonth=" & t.getMonth & _
-
"AND fldYear=" & t.getYear
-
What is the value for fldCountry ?
That looks like a pretty good candidate for why the update fails.
can you explain please what does this line of code means -
"UPDATE LNGproduction SET fldAmount=" & t.getAmount & "WHERE fldCountry=" & " AND" & t.getCountry & "' AND fldMonth=" & t.getMonth & _
-
"AND fldYear=" & t.getYear
-
What is the value for fldCountry ?
Is string ... i don't know where the mistake
Is string ... i don't know where the mistake
What my compatriots are alluding to is that you are attempting to perform an UPDATE which has a malformed WHERE clause. Your WHERE clause is malformed because you never specify a value for fldCountry.
I'm gonna try and bold the problem areas:
"UPDATE LNGproduction " _
"SET "_
"fldAmount=" & t.getAmount & _
"WHERE " _ "fldCountry=" & _
" AND " & t.getCountry & _
"' AND fldMonth=" & t.getMonth & _
"AND fldYear=" & t.getYear
As you notice there appears to be an extra "AND" in there, assuming that fldCountry should be tested with t.getCountry
Sign in to post your reply or Sign up for a free account.
Similar topics
by: kalamos |
last post by:
This statement fails
update ded_temp a
set a.balance = (select sum(b.ln_amt)
from ded_temp b
where a.cust_no = b.cust_no
and a.ded_type_cd = b.ded_type_cd
and a.chk_no = b.chk_no
group by...
|
by: Shapper |
last post by:
Hello,
I have created 3 functions to insert, update and delete an Access
database record. The Insert and the Delete code are working fine.
The update is not. I checked and my database has all...
|
by: HydroSan |
last post by:
Having a bit of a problem getting UPDATE working. The project in
question is a simple MySQL VB.NET frontend, allowing Insertion,
Selection, and others.
Well, I've gotten Drop and Insert working,...
|
by: Zorpiedoman |
last post by:
I keep getting a concurrency exception the second time I make a change and
attempt to update a dataadapter. It appears this is by design, so there must
be something I can do to avoid it.
...
|
by: Miro |
last post by:
I will ask the question first then fumble thru trying to explain myself so i
dont waste too much of your time.
Question / Statement - Every mdb table needs a PrimaryKey ( or maybe an
index - i...
|
by: travhale |
last post by:
in a new project using .net 2005, c#.
getting err message "Update requires a valid UpdateCommand when passed
DataRow collection with modified rows."
source RDBMS is oracle 8i. I add a new...
|
by: Nuzzi |
last post by:
Hello All,
I have two pages that are very similar. One is working, one is not. Here
is the code for both:
Page 1 (Working):
protected void btn_update_Click(object sender, EventArgs e)...
|
by: Brad Baker |
last post by:
I have a formview with a datasource that contains a select and update
command. The select statement works fine but the update command doesn't seem
to be working. After some troubleshooting I have...
|
by: Dilruba |
last post by:
asp, vbscript, Ms Access
I am using vbscript to insert & update ms accees.
Insert operation is working , but update operation is not working.
I have used the following codes:
...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |