Results 1 to 3 of 3

Thread: Database bug...

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2005
    Location
    my bat cave of a computer room
    Posts
    14

    Database bug...

    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:

    VB Code:
    1. Private Sub btnTransForm1_Click(ByVal sender As _
    2.     System.Object, ByVal e As System.EventArgs) Handles btnTransForm1.Click
    3.         Dim Words() As String = RemoveUnwantedCharacters(txtLangIn.Text).Split(" ")
    4.         Dim Output As String
    5.  
    6.         Dim n As Integer = 0
    7.         txtLangOut.Clear()
    8.  
    9.         For n = 0 To Words.Length - 1
    10.             Try
    11.                 'data base call code
    12.                 oledbcon.Open()
    13.                 strSQL = ("SELECT " & cbxLangOut.Text & " FROM English WHERE " _
    14.                                 & cbxLangIn.Text & " = '" & Words(n) & "'")
    15.  
    16.                 'Output = IsTableNull(oledbcon, "English", strSQL)
    17.                 'MsgBox(Output, , " ")
    18.  
    19.  
    20.                 cmd = New OleDb.OleDbCommand(strSQL, oledbcon)
    21.                 objRead = cmd.ExecuteReader
    22.  
    23.                 While objRead.Read
    24.                     If IsDBNull(objRead(cbxLangOut.Text)) Then
    25.                         MsgBox("Error", , " ")
    26.                     Else
    27.                         Me.txtLangOut.Text &= objRead(cbxLangOut.Text) & " "
    28.                     End If
    29.  
    30.  
    31.                 End While
    32.                 objRead.Close()
    33.             Catch ex As Exception
    34.                 MsgBox(ex.Message, MsgBoxStyle.Exclamation, "")
    35.  
    36.             Catch ex As System.Data.SqlTypes.SqlNullValueException
    37.                 MsgBox(ex.Message, MsgBoxStyle.Exclamation, "")
    38.             Finally
    39.                 oledbcon.Close()
    40.                 'For i As Integer = 0 To Output.Length - 1
    41.                 'txtLangOut.Text &= Output(i) + " "
    42.                 'Next
    43.             End Try
    44.         Next
    45.         gbIn.Text = cbxLangIn.Text
    46.         gbOut.Text = cbxLangOut.Text
    47.  
    48.  
    49.  
    50.     End Sub
    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.
    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?
    Last edited by Mysticshade; Mar 17th, 2005 at 07:25 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width