473,327 Members | 2,118 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

update not working

Expand|Select|Wrap|Line Numbers
  1. Imports System.XML
  2.  
  3. Public Class Form1
  4.     Inherits System.Windows.Forms.Form
  5.  
  6.  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  7.         transactions = New Transaction() {}
  8.         GCC.Open()
  9.     End Sub
  10.  
  11.     Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click
  12.         Dim action As String
  13.         Dim country As String
  14.         Dim month As Integer
  15.         Dim year As Integer
  16.         Dim amount As Double
  17.  
  18.         Dim document As XmlDocument
  19.         Dim reader As XmlNodeReader
  20.  
  21.         Dim ofd As OpenFileDialog = New OpenFileDialog
  22.         Dim result As DialogResult = ofd.ShowDialog
  23.         If (result = DialogResult.Cancel) Then
  24.             Return
  25.         End If
  26.  
  27.         document = New XmlDocument
  28.         document.Load(ofd.FileName)
  29.  
  30.         reader = New XmlNodeReader(document)
  31.  
  32.         reader.Read() 'skip root node
  33.         While reader.Read()
  34.             If (reader.Name = "transaction") Then
  35.                 reader.Read()
  36.                 action = reader.ReadElementString
  37.                 country = reader.ReadElementString
  38.                 month = reader.ReadElementString
  39.                 year = reader.ReadElementString
  40.                 amount = reader.ReadElementString
  41.                 ReDim Preserve transactions(transactions.Length)
  42.                 transactions(transactions.Length - 1) = New Transaction(action, country, month, year, amount)
  43.             End If
  44.         End While
  45.  
  46.         Try
  47.  
  48.             Dim t As Transaction
  49.             For Each t In Me.transactions
  50.  
  51.                 If t.getAction = "insert" Then
  52.                     LNGAdapter.InsertCommand.CommandText = _
  53.                     "INSERT INTO LNGproduction (fldCountry, fldMonth, fldYear, fldAmount ) VALUES('" & _
  54.                 t.getCountry & "', " & t.getMonth & ", " & t.getYear & ", " & t.getAmount & ")"
  55.                     LNGAdapter.InsertCommand.ExecuteNonQuery()
  56.  
  57.                 ElseIf (t.getAction = "update") Then
  58.                     LNGAdapter.UpdateCommand.CommandText = _
  59.                     "UPDATE LNGproduction SET fldAmount=" & t.getAmount & "WHERE fldCountry=" & " AND" & t.getCountry & "' AND fldMonth=" & t.getMonth & _
  60.                     "AND fldYear=" & t.getYear
  61.                     LNGAdapter.UpdateCommand.ExecuteNonQuery()
  62.  
  63.  
  64.                 ElseIf (t.getAction = "delete") Then
  65.                     LNGAdapter.DeleteCommand.CommandText = _
  66.                     "DELETE FROM LNGproduction WHERE fldCountry=" & " '" & t.getCountry & "' AND fldMonth=" & t.getMonth & _
  67.                     " AND fldYear=" & t.getYear
  68.                     LNGAdapter.DeleteCommand.ExecuteNonQuery()
  69.  
  70.                 End If
  71.             Next
  72.  
  73.         Catch oleDbExceptionParameter As System.Data.OleDb.OleDbException
  74.             Console.WriteLine(oleDbExceptionParameter)
  75.  
  76.         End Try
  77.  
  78.     End Sub
  79.  
  80.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  81.  
  82.         LNGAdapter.SelectCommand.CommandText = TextBox1.Text
  83.         LngDataSet.Clear()
  84.         LNGAdapter.Fill(LngDataSet, "LNGproduction")
  85.         DataGrid1.SetDataBinding(LngDataSet, "LNGproduction")
  86.  
  87.     End Sub
  88.  
  89. End Class

The update not working with me i don't know why
Nov 12 '07 #1
5 1361
debasisdas
8,127 Expert 4TB
can you explain please what does this line of code means
Expand|Select|Wrap|Line Numbers
  1. "UPDATE LNGproduction SET fldAmount=" & t.getAmount & "WHERE fldCountry=" & " AND" & t.getCountry & "' AND fldMonth=" & t.getMonth & _
  2.                     "AND fldYear=" & t.getYear
  3.  
What is the value for fldCountry ?
Nov 12 '07 #2
Plater
7,872 Expert 4TB
can you explain please what does this line of code means
Expand|Select|Wrap|Line Numbers
  1. "UPDATE LNGproduction SET fldAmount=" & t.getAmount & "WHERE fldCountry=" & " AND" & t.getCountry & "' AND fldMonth=" & t.getMonth & _
  2.                     "AND fldYear=" & t.getYear
  3.  
What is the value for fldCountry ?
That looks like a pretty good candidate for why the update fails.
Nov 12 '07 #3
can you explain please what does this line of code means
Expand|Select|Wrap|Line Numbers
  1. "UPDATE LNGproduction SET fldAmount=" & t.getAmount & "WHERE fldCountry=" & " AND" & t.getCountry & "' AND fldMonth=" & t.getMonth & _
  2.                     "AND fldYear=" & t.getYear
  3.  
What is the value for fldCountry ?

Is string ... i don't know where the mistake
Nov 13 '07 #4
Motoma
3,237 Expert 2GB
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.
Nov 13 '07 #5
Plater
7,872 Expert 4TB
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
Nov 13 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

17
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...
3
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...
5
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,...
8
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. ...
2
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...
2
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...
6
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)...
3
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...
3
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: ...
0
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
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...
0
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...
0
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...
0
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...
1
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)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
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

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.