- 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 1380
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 ?
Plater 7,872
Recognized Expert Expert
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
Motoma 3,237
Recognized Expert Specialist
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.
Plater 7,872
Recognized Expert Expert
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 cust_no, ded_type_cd, chk_no)
|
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 the necessary
records in it when testing it. I get the error "No value given for one
or more required parameters." when I try to update the database.
Can you tell me what am I doing wrong?
|
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, but to edit a table row,
I'd like to use Update.
I have the following code in a class:
Private Function SQL_CustomerUpdate()
|
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.
Example:
I have a dataadapter that contains one table with one row. I change the
value of the 'FisrtName' column in that row from Jack to John. I call
..update on the dataadapter it goes through fine. Now I change that same
column in that same row...
|
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 havnt tested the index yet ) so you
can use an .UPDATE( dataTable ) on the data adapter. Otherwise you will
get an exception error.
Is this statement true?
---- Now me fumbling thru
| |
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 dataset to the project and drag
a datatable from server explorer onto the dataset design surface. In
the configuration wizard, under advanced options the "refresh data
table" is disabled ie I am not able to check it (note if the source db
is sql...
|
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)
{
Int32 item_id = Convert.ToInt32(ViewState);
|
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 narrowed the problem down
to the department_id parameter which is set from a hidden field.
I can confirm this by hard coding the UpdateCommand to: UPDATE configuration
SET special_notes=@special_notes WHERE (student_id=@student_id) AND...
|
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:
connectionString = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:\progam files\mail.mdb"
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |