473,664 Members | 2,797 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

update not working

11 New Member
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 1380
debasisdas
8,127 Recognized Expert Expert
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 Recognized Expert Expert
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
qatarya3sal
11 New Member
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 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.
Nov 13 '07 #5
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
Nov 13 '07 #6

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

Similar topics

17
5006
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)
3
3441
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?
5
4165
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()
8
2689
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...
2
3101
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
2
11150
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...
6
2650
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);
3
4798
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...
3
1781
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"
0
8437
marktang
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...
0
8348
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,...
1
8549
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,...
1
6187
isladogs
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...
0
5660
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();...
0
4185
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...
1
2764
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
2
2003
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1759
bsmnconsultancy
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...

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.