| | |
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!
![]() |
•
•
Join Date: Dec 2008
Posts: 1
Reputation:
Solved Threads: 0
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
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
•
•
Join Date: Jan 2008
Posts: 9
Reputation:
Solved Threads: 1
VB.NET Syntax (Toggle Plain Text)
UTop = UBound(ItemArray) ULower = LBound(ItemArray) For lCtr As Integer = ItemElement To UTop - 1 ItemArray(lCtr) = ItemArray(lCtr + 1) Next ReDim Preserve ItemArray(ULower To UTop - 1)
![]() |
Other Threads in the VB.NET Forum
- Previous Thread: Error In trigger.
- Next Thread: create dll using vb.net and how to call it from sql server
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2008 access add application arithmetic array assignment basic beginner box button buttons click code combo component connectionstring convert cpu cuesent data database databasesearch datagrid datagridview datetimepicker design designer dissertation dissertations dissertationthesis dosconsolevb.net editvb.net exists firewall folder forms html image images isnumericfuntioncall listview math mobile module mssqlbackend mysql navigate number opacity open peertopeervideostreaming picturebox1 picturebox2 port print printpreview problemwithinstallation project record regex reports" reuse right-to-left savedialog serial settings socket sqldatbase sqlserver storedprocedure string temp textbox timer txttoxmlconverter updown useraccounts usercontol usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vbnet view vista visual visualbasic visualbasic.net visualstudio visualstudio.net web wpf wrapingcode xml





