| | |
adding data to listview
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: May 2009
Posts: 20
Reputation:
Solved Threads: 0
Hi,
Currently having troubles in adding data to the listview i have created. It actually will add the first set of data to both the database and listview, but when i try to add a second lot of data it displays the error message that I have setup. Also how would I go about updating the same item with different amount of quantity but not adding a new set of row to it ? using the UPDATE method?
Currently having troubles in adding data to the listview i have created. It actually will add the first set of data to both the database and listview, but when i try to add a second lot of data it displays the error message that I have setup. Also how would I go about updating the same item with different amount of quantity but not adding a new set of row to it ? using the UPDATE method?
VB.NET Syntax (Toggle Plain Text)
Private Function listview() Dim lSingleItem As ListViewItem 'The variable will hold the ListItem information so that you can add values to the column you want to change lSingleItem = ListView1.Items.Add(txtItemNo.Text.Trim) 'Create a new line, and assign the ListItem into the variable so we can add sub items lSingleItem.SubItems.Add(txtItemName.Text.Trim) 'The first sub item for the first line lSingleItem.SubItems.Add(FormatCurrency(txtUnitPrice.Text.Trim)) 'The second sub item for the first line lSingleItem.SubItems.Add(txtQty.Text.Trim) lSingleItem.SubItems.Add(FormatCurrency(txtUnitTotal.Text.Trim)) ' total = total + Val(txtTotal.Text.Trim) 'lblSubTotal.Text = total End Function Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click Try Dim strSQL As String strSQL = "INSERT INTO trans2 (trans_ID, Item_ID, ItemName, Price, Qty, Total)VALUES (""" & txttran.Text & """ , """ & txtItemNo.Text & """ , """ & txtItemName.Text & """ , """ & txtUnitPrice.Text & """, """ & txtQty.Text & """ , """ & txtUnitTotal.Text & """)" dc.Open() MessageBox.Show(strSQL) Dim cmd As New OleDbCommand(strSQL, dc) cmd.ExecuteNonQuery() Call listview() Catch MessageBox.Show("Error occured when trying to save data!", "Sale", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) txtItemNo.Focus() End Try 'dc.Close() txtItemNo.Clear() txtItemName.Clear() txtQty.Clear() txtUnitPrice.Clear() txtUnitTotal.Clear() End Sub
Last edited by BlkR; Jul 27th, 2009 at 4:17 am.
Single quote needed.
vb.net Syntax (Toggle Plain Text)
strSQL = "INSERT INTO trans2 (trans_ID, Item_ID, ItemName, Price, Qty, Total)VALUES ('" & txttran.Text & "'" , "'" & txtItemNo.Text & "'" , "'" & txtItemName.Text & "'" , "'" & txtUnitPrice.Text & "'", "'" & txtQty.Text & "'" , "'" & txtUnitTotal.Text & "')"
Last edited by adatapost; Jul 27th, 2009 at 8:57 am.
Failure is not fatal, but failure to change might be. - John Wooden
![]() |
Similar Threads
- OWC11.0 columnClustered chart control-Adding more data series and displaying in chart (ASP.NET)
- problem in making listview (Visual Basic 4 / 5 / 6)
- Listview Column data to XML file (VB.NET)
- Adding Data from class (Java)
- Adding a data structure (that contains a linked list) to a linked list! (C)
- adding data to sql db (ASP.NET)
- How to adding new data to database (Visual Basic 4 / 5 / 6)
- VB.Net: Problem Retrieve data from ListView (VB.NET)
Other Threads in the VB.NET Forum
- Previous Thread: delete control at certal x and y point
- Next Thread: Steel cutting problem
| Thread Tools | Search this Thread |
"crystal .net .net2005 2008 access add advanced application array assignment basic beginner box button buttons center click code combo convert cpu cuesent data database datagrid datagridview designer dissertation dissertations dissertationthesis dosconsolevb.net editvb.net employees excel exists firewall forms html image images isnumericfuntioncall listview login map math memory mobile module msaccess mssqlbackend mysql navigate net number opacity open pan picturebox picturebox2 port print printpreview record regex reports" reuse right-to-left save savedialog search serial settings socket sorting sqldatbase sqlserver storedprocedure string temp textbox timer txttoxmlconverter upload useraccounts usercontol usercontrol vb vb.net vb.nettoolboxvisualbasic2008sidebar vba vbnet vista visual visualbasic visualbasic.net visualstudio.net web wpf wrapingcode xml






