back up codes

always have a backup of your code

Archive for the tag “remove”

remove listbox item if it is already on database

This code will remove items to be displayed on a listbox if already inputed on databse:

On DataBound event of listbox control insert this code:


Dim mypk As String
Dim i As Integer
For i = 0 To myListBox.Items.Count - 1
If i = myListBox.Items.Count Or i > myListBox.Items.Count Then
Else
mypk = myListBox.Items(i).ToString()
command = New Data.SqlClient.SqlCommand("SELECT * FROM MYTABLE WHERE MYPK = '" & mypk & "'", connection)
reader = command.ExecuteReader()
If reader.Read() Then
myListBox.Items.RemoveAt(i)
i = i - 1
Else
End If
reader.Close()
End If
Next

clear dataset

The following code would manipulate data on a dataset.

This code clears the dataset:

myDataset.Clear

This code adds table to the dataset:

myDataset.Tables.Add("myTable")

This code will remove table from a dataset:

myDataset.Tables.Remove("myTable")

Post Navigation

Follow

Get every new post delivered to your Inbox.