|
-
Oct 13th, 2010, 03:40 PM
#1
Thread Starter
Member
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
-
Oct 13th, 2010, 03:54 PM
#2
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
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Oct 13th, 2010, 03:58 PM
#3
Re: HELP about simple application
vb Code:
DirectCast(item, DataRowView).Item("due_date")
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Oct 13th, 2010, 04:04 PM
#4
Thread Starter
Member
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")
-
Oct 13th, 2010, 04:05 PM
#5
Re: HELP about simple application
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Oct 13th, 2010, 04:09 PM
#6
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
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Oct 13th, 2010, 04:12 PM
#7
Thread Starter
Member
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.
-
Oct 13th, 2010, 04:27 PM
#8
Thread Starter
Member
Re: HELP about simple application
thanks bro! 
is it possible that my items in my listbox will be updated automatically without opening again the application?
-
Oct 13th, 2010, 04:30 PM
#9
Re: HELP about simple application
 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
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Oct 13th, 2010, 04:50 PM
#10
Thread Starter
Member
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?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|