Remove string items from array if match with datareader items.

Please support our VB.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Reply

Join Date: Dec 2008
Posts: 1
Reputation: VINITSONI is an unknown quantity at this point 
Solved Threads: 0
VINITSONI VINITSONI is offline Offline
Newbie Poster

Remove string items from array if match with datareader items.

 
0
  #1
Dec 2nd, 2008
Dear Friends.

Q:The problem in my coding is: I want to remove items from the string array if if does match with datareader field called time1 whose number in the Sql database is 4.

Would u pls tell me whats wrong with my coding .?
Its urgent..

With Regards,
Vinit.


Private Sub DateTimePicker2_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker2.ValueChanged
If myConnection.State = ConnectionState.Open Then

myConnection.Close()
End If
myConnection.Open()

If dr.IsClosed = True Then

dr = myCommand.ExecuteReader()
End If
ListBox3.Items.Clear()
Dim ar1() As String = {"0900:0930", "0930:1000", "1000:1030", "1030:1100", "1100:1130", "1130:0000", "1200:1230", "1230:1300", "1300:1330", "1330:1400", "1400:1430", "1430:1500", "1500:1530", "1530:1600", "1600:1630", "1630:1700"}
TextBox1.Text = DateTimePicker2.Value
DateTimePicker2.MinDate.ToString("dd/MM/yyyy")
DateTimePicker2.MaxDate.ToString("dd/MM/yyyy")
TextBox1.Text = (DateTimePicker2.Value.Date & " 0:00:00")

Label2.Visible = True


Label3.Visible = True
ListBox3.Visible = True

myCommand = New SqlCommand("Select * from appointment where ( date1 = CONVERT(DATETIME, '" & DateTimePicker2.Value.Date & "', 103)) ", myConnection)
If dr.IsClosed = True Then

dr = myCommand.ExecuteReader()
End If


Dim i As Integer
If dr.HasRows() Then

With dr
.Read()

Do While .HasRows

For i = 0 To 14
If ((ar1(i).CompareTo(dr(4))) = True) Then
‘ I want to delete listitems that are same
‘ MsgBox(ar1(i))
Else
‘remaining times in the list should appear on listbx.
ListBox3.Items.Add(ar1(i))
End If

Next i
.NextResult()
Loop

End With

dr.Close()

Else
For i = 0 To 14

ListBox3.Items.Add(ar1(i))

Next i
End If

End Sub
End Class
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 9
Reputation: CornerAnalyst is an unknown quantity at this point 
Solved Threads: 1
CornerAnalyst CornerAnalyst is offline Offline
Newbie Poster

Re: Remove string items from array if match with datareader items.

 
0
  #2
Dec 2nd, 2008
  1. UTop = UBound(ItemArray)
  2. ULower = LBound(ItemArray)
  3.  
  4. For lCtr As Integer = ItemElement To UTop - 1
  5. ItemArray(lCtr) = ItemArray(lCtr + 1)
  6. Next
  7.  
  8. ReDim Preserve ItemArray(ULower To UTop - 1)
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC