Datareader Retrieving Data

老子叫甜甜 提交于 2019-12-02 13:32:59

Try explicitly stating that you want an INNER JOIN instead:

str2 = "select m.cust_id from Memberships AS M " &_
       " INNER JOIN Bookings AS B ON B.cust_id = M.cust_id;"

When comparing, use String.Compare(), and make sure you're trimming whitespace, just in case.

Dim str1 As String = MskdTxtCustId.Text.Trim()
Dim str3 As String = bookchk("cust_id").ToString().Trim()

Dim compareResult As Integer = String.Compare(s1, s2)
MessageBox.Show("compare str1: {0}, str3: {1}, result: {2}" , str1, str3, compareResult)

compareResult = String.Compare(s1, s2, True)
MessageBox.Show("Compare insensitive. result: {0}", compareResult)

As for String compare: I always use Datareader.GetString(item) as in this Sub:

    If IsDBNull(Dr.Item(nr)) Then
        Return ""
    Else
        Return Dr.GetString(nr).TrimEnd
    End If

where nr identifies the row to fetch a value from. You are using some default method to convert the database value to the program variable. I rather write what I want.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!