Question Getting data from access database

Doctor GME

New member
Joined
Jun 25, 2015
Messages
1
Programming Experience
Beginner
i'm coding dictionary program dealing with idoms and sentences

as example if i wrote on english textbox:

949794485.jpg



it suppose to get this row from arabic column in database:

750416925.jpg



and applied in arabic textbox like this:

981597057.jpg



as the first line is arabic translation

and the second phrase means: (another meaning for this)

but i found the result like this:

396631398.jpg


as the marked word is arabic translation for (okay)
when i searched my database i found this row:
Resized to 87% (was 575 x 22) - Click image to enlarge
656718698.jpg



so the program applied the function twice

first on the text in english textbox

and second with the translated text itself, i want only the first

code for this function:

VB.NET:
    Function getidom(ByVal content As String) As String        Try
            Dim count As Integer = 0
            Using adp As New OleDb.OleDbDataAdapter("SELECT * FROM [Idoms]", connectionString)
                Using tbl As New DataTable
                    If adp.Fill(tbl) > 0 Then
                        For Each row As DataRow In tbl.Rows
                            Dim en As String = row.Item("English").Replace("?", "\?")
                            Dim ar As String = row.Item("Arabic")
                            count += Regex.Matches(content, en, RegexOptions.IgnoreCase).Count
                            content = Regex.Replace(content, en, ar, RegexOptions.IgnoreCase)
                        Next
                    End If
                End Using
            End Using
            Return content
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        getidom = ""

    End Function




also the translation button click code:

VB.NET:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox2.Text = getidom(TextBox1.Text)


 

Latest posts

Back
Top