开发者

How to refer to a text in an Ms Access table?

I want to refer to a data cell, which if it is equals to some string, it will do something. The codes:

If ds.Tables(0).Rows(i)("Status") =开发者_JAVA技巧 "Reserved" Then
MessageBox.Show("Can't reserve")
End If

Is this the correct way to do this? Because I failed doing so..


Check the return type of:

ds.Tables(0).Rows(i)("Status")

Also,

  • Is the case different (uppercase in db ??)

  • Check for leading/trailing spaces.

  • Is the field in database fixed-length

U might want to try trim-ing the string before comparing:

For Ex, in VB6 i might hav tried:

IF lower(trim$(<thedbqueryhere>))= "reserved" then

    msgBox("Can't reserve")

End if

GoodLUCK!!

CVS @ 2600Hertz


You probably need to be checking the Value property of the cell.

Also here is the VB6 code by CVS @ 2600Hertz translated to VB.NET

Dim cell = ds.Tables(0).Rows(i)("Status")
If cell.Value.ToUpperInvariant().Trim() = "Reserved".ToUpperInvariant() Then
    MessageBox.Show("Can't Reserve")
End If
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜