473,394 Members | 1,841 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,394 software developers and data experts.

How can I delete a Row from a database listed in a listview control in vb.net 2008?

I've tried the following code but it doesn't delete and no error message received.

Expand|Select|Wrap|Line Numbers
  1. Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
  2.         Dim Station As String = ""
  3.  
  4.         For Each sItem As ListViewItem In lvList.SelectedItems
  5.             Station = Station & sItem.Text
  6.         Next
  7.  
  8.         If Station <> "" Then
  9.             'Delete the selected record
  10.             Dim strDeleted As Boolean
  11.             strDeleted = ExecNonQuery("DELETE * from FuelDistribution WHERE ToStation = '" & Station & "'")
  12.  
  13.             If strDeleted = "True" Then
  14.                 MsgBox("Record's deleted.", MsgBoxStyle.Information)
  15.                 Call FillList()
  16.             Else
  17.                 MsgBox(strDeleted)
  18.             End If
  19.         Else
  20.             MsgBox("Please select record to delete.", MsgBoxStyle.Critical)
  21.         End If
  22.  
  23.     End Sub
Sep 1 '09 #1
1 4593
yarbrough40
320 100+
try omitting the "*" in your sql statement.


instead of
Expand|Select|Wrap|Line Numbers
  1. "DELETE * from FuelDistribution WHERE ToStation = '" & Station & "'"
  2.  
try
Expand|Select|Wrap|Line Numbers
  1. "DELETE from FuelDistribution WHERE ToStation = '" & Station & "'"
  2.  
Sep 13 '09 #2

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

Similar topics

0
by: Silvia | last post by:
Hi, I have a program that capture images and put this into a listview (using imagelist), the problem is when I delete de image the listview, when do that and capture another image, the image...
9
by: Nathan Sokalski | last post by:
I am trying to connect to a Microsoft Access Database from my ASP.NET Application. I use the following code to create my connection string: cmdSelect.Connection = New...
0
by: Silvia | last post by:
Hi, I have a program that capture images and put this into a listview (using imagelist), the problem is when I delete de image the listview, when do that and capture another image, the image...
0
by: Mamatha | last post by:
Hi I have a listview control in VB.NET application. In that list view,i have displayed data like rows from database. For example columns are A,B and C. A B C xx 0 0
1
by: =?Utf-8?B?SmVzcGVyLCBEZW5tYXJr?= | last post by:
Hi, I've recently replaced a CheckedListBox control with a ListView control, however I'm missing the SelectedItem set functionality, its equivalent in ListView, SelectedItems, is only...
1
by: shapper | last post by:
Hello, I have a ListView connected to a LinqDataSource. It uses a table, named Tags, with 2 fields: TagId and Text. I need to add a column named active. For this I created a LinqDataSource...
0
by: shapper | last post by:
Hello, I am trying to define an ObjectDataSource delete parameter. The parameter name is "TagID" and is a Guid: ObjectDataSource1.DeleteParameters.Add(new Parameter("ID", TypeCode.Object)) ...
5
by: Joza | last post by:
Hi! I'm getting error when selecting items in ListView control, it says ArguementOutOfRangeExceptions. That happens in SelectIndexChange event. I have tryed with try...catch but there's no...
8
by: Michel Esber | last post by:
Hello, Env: DB2 V8 LUW FP16 running Linux create Table X (machine_id varchar(24) not null, ctime timestamp not null); create index iFoo on X (MACHINE_ID, CTIME) allow reverse scans; alter...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.