Click here to Skip to main content
15,898,134 members

Comments by hoyice (Top 34 by date)

hoyice 30-Oct-13 2:41am View    
do you have any link for how timer works? I'm new to WPF and VB.NET sir.
hoyice 30-Aug-13 4:43am View    
i am doing my interface to expression blend and i code in vb.net because my data is from SQL. I am not familiar with view model.
hoyice 25-Aug-13 0:44am View    
I've already figured it out.

I used this code:

Imports MySql.Data.MySqlClient
Imports System.Data

Class MainWindow
Private oskProcess As Process
Dim conn As MySqlConnection
Dim sql As String
Dim cmd As MySqlCommand
Dim adapter As MySqlDataAdapter
Dim table As DataSet
Dim reader As MySqlDataReader




Private Sub Window_Loaded(sender As Object, e As RoutedEventArgs) Handles Window.Loaded
conn = New MySqlConnection()
conn.ConnectionString = "server=localhost;username=root;password=;database=kiosk"

conn.Open()

sql = "select name from establishments where category='accommodation' and location = 'town' order by name asc"
cmd = New MySqlCommand(sql, conn)
adapter = New MySqlDataAdapter()
adapter.SelectCommand = cmd


Using reader As MySqlDataReader = cmd.ExecuteReader

While (reader.Read())
Me.listBox.Items.Add(reader("name"))

End While
End Using
conn.Close()

End Sub



Private Sub listBox_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles listBox.SelectionChanged
Dim y As String = listBox.SelectedItem
Dim x As Double
Dim j As Double
Dim k As String
Dim r As Integer
Dim l As String
Dim d As String
Dim a As Image = New Image()
Dim can As New Canvas()


conn.Open()
cmd = New MySqlCommand(String.Format("SELECT * FROM establishments where name='{0}'", y.ToString()), conn)

Using reader As MySqlDataReader = cmd.ExecuteReader
While reader.Read
x = (reader("top"))
j = (reader("l"))
k = (reader("name"))
r = (reader("Contact_Num"))
l = (reader("Distance"))
d = (reader("Description"))

can = Map
a = Bal_Pointer

Canvas.SetTop(a, x)
Canvas.SetLeft(a, j)

can.Children.Remove(Bal_Pointer)
can.Children.Add(a)

tb_1.Text = k
tb_2.Text = r
tb_3.Text = l
tb_4.Text = d

End While
End Using

conn.Close()

End Sub

Private Sub tb1_MouseDoubleClick_1(sender As Object, e As MouseButtonEventArgs) Handles tb1.MouseDoubleClick
oskProcess = Process.Start("osk")

End Sub


Private Sub Tb1_TextChanged_1(sender As Object, e As TextChangedEventArgs) Handles tb1.TextChanged

conn.Open()

Dim lb As New ListBox
lb = listBox

cmd = New MySqlCommand(String.Format("select name from establishments where name like '{0}%' and category = 'accommodation' and location = 'town' order by name asc", tb1.Text), conn)

lb.Items.Clear()
Using reader As MySqlDataReader = cmd.ExecuteReader
While reader.Read
lb.Items.Add(reader("name"))

End While

End Using
conn.Close()
End Sub




End Class



------> THE PPROBLEM IS ----> whenever i typed a in the textbox, list box will show apple and avocado, if i select apple the functions seems to pretty work well. BUT whenever i change the letter in to textbox, the program doesn't work, it says there is a problem in conn.open.

how will i able to run this without problem?
hoyice 24-Aug-13 21:04pm View    
Deleted
what's the appropriate code for the text changed event, if i may ask?
hoyice 24-Aug-13 1:48am View    
Private Sub Tb1_TextChanged_1(sender As Object, e As TextChangedEventArgs) Handles tb1.TextChanged

conn.Open()


cmd = New MySqlCommand(String.Format("select name from establishments where name like '{0}' and category = 'accommodation' and location = 'town'", tb1.Text), conn)

Using reader As MySqlDataReader = cmd.ExecuteReader
While reader.Read
listBox.Items.Add(reader("name"))

End While

End Using
conn.Close()
End Sub


i'm using this code but nothing happens. i don't see the list on the listbox.