vb.net read mysql table columns no matter what field type in mysql -


i runnig code inside reader loop:

while reader.read x = 0 reader.fieldcount - 1     msgbox(reader.getvalue(x))     dim find_text string = "<<" & reader.getname(x) & ">>"     dim replacet_text string = reader.getstring(x)      odoc.content.find.execute(findtext:=find_text, replacewith:=replacet_text, replace:=word.wdreplace.wdreplaceall) next end while 

so showing every column sql query says select * table1

but issue is, depending on type of column in database showing errors cannot converted type 'string'.

how can columns no matter type? want read string

try dim replacet_text string = reader.getvalue(x).tostring , if failed means type not convertible string can place line of code in try catch block , place error message when data not convertible string:

while reader.read x = 0 reader.fieldcount - 1     msgbox(reader.getvalue(x))     dim find_text string = "<<" & reader.getname(x) & ">>"     dim replacet_text string     try         replacet_text = reader.getvalue(x).tostring()     catch ex exception         replacet_text = "-- not available! --"     end try     odoc.content.find.execute(findtext:=find_text, replacewith:=replacet_text, replace:=word.wdreplace.wdreplaceall) next end while 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -