| | |
Remove string items from array if match with datareader items.
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
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 2005 2008 access arithmetic array assignment basic binary bing box button buttons center check code combobox component connectionstring convert cpu crystalreport data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dosconsolevb.net dropdownlist editvb.net employees excel file-dialog firewall folder ftp google hardcopy image images isnumericfuntioncall login math memory mobile ms mssqlbackend mysql navigate net networking opacity output peertopeervideostreaming picturebox1 port printpreview problemwithinstallation project record reports" reuse save savedialog searchbox serial soap storedprocedure string tcp temp text textbox timer toolbox trim updown useraccounts usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet view vista visual visualbasic visualbasic.net visualstudio web wpf





