Why am I getting InvalidCastException passing a string to a VariantType parameter?
I have:
Protected Sub SepInsert(ByVal mriId As VariantType,
ByVal aeId As VariantType,
ByVal absId As VariantType)
...
End Sub
and want to call it with a DropDownList selection like this:
Protected Sub cmdNewPrelinkedMri_Click(ByVal sender As Object,
ByVal e As System.EventArgs
) Handles cmdNewPrelinkedMri.Click
SepInsert(ddlMriUnassigned.SelectedValue, -1, -1)
End Sub
where the ddl selected value is, of course, a string (e.g., "0412B0").
I am getting an InvalidCastException saying: Conversion from st开发者_运维问答ring "0412B0" to type 'Integer' is not valid. Why does it want to convert to 'Integer' when the parameter is declared as VariantType?
What am I misunderstanding or doing wrong? Thanks,
Chris
Some statement in SepInsert is trying to force mriId into an int. Show the whole code if you can't find it.
精彩评论