i am writing a program that allows the user to set the search criteria when accessing my data base. it is a simple one table 4 column DB. this is a VERY simple translation program that is intended to translate a whole sentence. the sentence is split up into an array and each word is processed indiviually. the problem occurs when the user inputs a word that is not in the DB. it will act as if it skipped over that word.
for example: if i was translating from engish to english...(just to point this bug out)... the sentence "the boy is sitting on the red table" it would be translated into "the is on the red table" because both "boy" and "sitting" are not listed in the data base... what expresion or boolean term can i use to show on the front end that this has happened?
code to follow:
as you can see i have been trying to see if it is coming out as an Null value but nothing i have tryed has worked... any help would be greatly appreciated.VB Code:
Private Sub btnTransForm1_Click(ByVal sender As _ System.Object, ByVal e As System.EventArgs) Handles btnTransForm1.Click Dim Words() As String = RemoveUnwantedCharacters(txtLangIn.Text).Split(" ") Dim Output As String Dim n As Integer = 0 txtLangOut.Clear() For n = 0 To Words.Length - 1 Try 'data base call code oledbcon.Open() strSQL = ("SELECT " & cbxLangOut.Text & " FROM English WHERE " _ & cbxLangIn.Text & " = '" & Words(n) & "'") 'Output = IsTableNull(oledbcon, "English", strSQL) 'MsgBox(Output, , " ") cmd = New OleDb.OleDbCommand(strSQL, oledbcon) objRead = cmd.ExecuteReader While objRead.Read If IsDBNull(objRead(cbxLangOut.Text)) Then MsgBox("Error", , " ") Else Me.txtLangOut.Text &= objRead(cbxLangOut.Text) & " " End If End While objRead.Close() Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Exclamation, "") Catch ex As System.Data.SqlTypes.SqlNullValueException MsgBox(ex.Message, MsgBoxStyle.Exclamation, "") Finally oledbcon.Close() 'For i As Integer = 0 To Output.Length - 1 'txtLangOut.Text &= Output(i) + " " 'Next End Try Next gbIn.Text = cbxLangIn.Text gbOut.Text = cbxLangOut.Text End Sub
Thanks
-Will-
PS. i honestly don't know enough to really tweak code with database calls, any good books i can get to that would be useful and maybe instructional?




Reply With Quote