Share via

Simple Question

OSVBNET 1,401 Reputation points
2022-04-24T15:29:27.4+00:00

Hello,
Please advise about Option Strict:

Dim ProxyCMD As New OleDb.OleDbCommand("SELECT * FROM Proxy", MyConnection)
Dim ProxyDBR As OleDbDataReader = ProxyCMD.ExecuteReader
ProxyDBR.Read()

Now my gathered data:

ProxyDBR("DataField1")

It can be either boolean or integer!

To conform with Option Strict, you advise which method?

Convert.ToInt32/ToBoolean(ProxyDBR("DataField1").ToString)

Convert.ToInt32/ToBoolean(ProxyDBR("DataField1"))

I mean because ProxyDBR("DataField1") is As System.Data.OleDb.OleDbDataReader, shall I convert it .ToString first and then convert to Boolean or Integer or .ToString is not needed?

Developer technologies | VB
0 comments No comments

Answer accepted by question author

Jiachen Li-MSFT 34,241 Reputation points Microsoft External Staff
2022-04-25T09:35:46.37+00:00

Hi @OSVBNET ,
option strict on does not allow late binding, it only affects implicit conversion, and has no effect on display conversion.
So toString() is not required if the data is legal.
Best Regards.
Jiachen Li

----------

If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Was this answer helpful?


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.