HELP about simple application
hi! i am creating an application that is like an alarm, for example an item in my listbox is "2010-10-24" and the date in my label is also "2010-10-24".
i would like to pop a message that there is a due paper in that date.
my problem is my code below, it does not find the item in listbox and the label equal. i wonder what is the problem, can anyone help me? thanks alot!
Code:
Dim connectionstring As String
Dim query As String
Dim adapter As MySqlDataAdapter
Dim table As DataTable
connectionstring = "server=localhost;uid=root;pwd=passw0rd;database=purchasing"
query = "SELECT due_date FROM request ORDER BY due_date ASC"
Try
adapter = New MySqlDataAdapter(query, connectionstring)
table = New DataTable
adapter.Fill(table)
ListBox1.DataSource = table
ListBox1.DisplayMember = "due_date"
For Each item In ListBox1.Items
If item.ToString = Label1.Text Then
MsgBox("There is a Due Paper today")
End If
Next
Re: HELP about simple application
try this. i think you'll find that item.ToString is "Datarow" or "Datarowview"
you need to cast item to that type + check the field against your label text
vb Code:
For Each item In ListBox1.Items
msgbox(item.ToString)
If item.ToString = Label1.Text Then
MsgBox("There is a Due Paper today")
End If
Next
Re: HELP about simple application
vb Code:
DirectCast(item, DataRowView).Item("due_date")
Re: HELP about simple application
hi paul! thanks for helping again.
msgbox only displays "system.data.datarowview"
can you explain what you said recently that "i need to cast item to that type + check the field against your label text"
by the way my
Code:
label1.text = Date.Now.ToString("yyyy-MM-dd")
Re: HELP about simple application
Re: HELP about simple application
vb Code:
For Each item In ListBox1.Items
If DirectCast(item, DataRowView).Item("due_date") = Label1.Text Then
MsgBox("There is a Due Paper today")
End If
Next
Re: HELP about simple application
Code:
For Each item In ListBox1.Items
Dim a As String = DirectCast(item, DataRowView).Item("due_date")
MsgBox(a)
If item.ToString = Label1.Text Then
MsgBox("There is a Due Paper today")
End If
Next
did i do it right? im sorry, i am not familiar with directcast.
well this code only displays the items in my listbox.
Re: HELP about simple application
thanks bro! :D
is it possible that my items in my listbox will be updated automatically without opening again the application?
Re: HELP about simple application
Quote:
Originally Posted by
markirving
is it possible that my items in my listbox will be updated automatically without opening again the application?
you'd have to requery the db + rebind the listbox
Re: HELP about simple application
hmm ok... so how am i suppose to write that? because my application is on the form_load.
is rebind like refresh?