ChatBot with DataBase

  • Thread starter Thread starter Mateusz Myślak
  • Start date Start date
M

Mateusz Myślak

Guest
Hello Guys!

I'm using VB 10 and I have a little problem with my program...

I have three columns in my database - id, questions and answers, but I don't know how I can write the code so that after entering the data saved in the question column, the script would download them to TextBox1 and at the same time the bot would answer by downloading the answer from the answer column to TextBox2. I have sample code but it only downloads one specific line and not the entire pool of questions and answers.
Can somebody help me?

Here is my code:

Public Class Form1

Private xmlDataBaseData As String = My.Application.Info.DirectoryPath & "\xmlData.xml"

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If My.Computer.FileSystem.FileExists(xmlDataBaseData) = True Then
XmlDataSet.ReadXml(xmlDataBaseData)
End If
End Sub

Private Sub ConversationsBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ConversationsBindingNavigatorSaveItem.Click
Me.Validate()
ConversationsBindingSource.EndEdit()
XmlDataSet.WriteXml(xmlDataBaseData)
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ConversationsBindingSource.Filter = String.Format("{0} LIKE '{0}'", "Questions", TextBox1.Text)

Dim Voice
Voice = CreateObject("SAPI.spvoice")

If TextBox1.Text = XmlDataSet.Tables("Conversations").Rows(0).Item(1) Then
TextBox2.Text = XmlDataSet.Tables("Conversations").Rows(0).Item(2)
Voice.Speak(TextBox2.Text)
End If

Dim input As String
input = TextBox1.Text

If input.Contains(XmlDataSet.Tables("Conversations").Rows(0).Item(1)) Then
TextBox3.AppendText("User: " & XmlDataSet.Tables("Conversations").Rows(0).Item(1) & vbNewLine & "Computer: " & XmlDataSet.Tables("Conversations").Rows(0).Item(2) & vbNewLine)
End If

TextBox1.Clear()
End Sub
End Class

Continue reading...
 
Back
Top