sqlParameters Array in VB.Net -
i'm trying create typed-sized parameters array in vb.net:
dim parameters() sqlparameter = new sqlparameter() _ { new sqlparameter("@first_name", sqldbtype.varchar, 50) {value = "john"}, new sqlparameter("@last_name", sqldbtype.varchar, 50) {value = "doe"}, new sqlparameter("@age", sqldbtype.int) {value = 18}, new sqlparameter("@id", sqldbtype.int) {value = 123} }
but vs says: value' not declared. may inaccessible due protection level
what's wrong code above?
thanks!
you need use vb syntax object initializers:
dim parameters() sqlparameter = new sqlparameter() _ { new sqlparameter("@first_name", sqldbtype.varchar, 50) { .value = "john"}, new sqlparameter("@last_name", sqldbtype.varchar, 50) { .value = "doe"}, new sqlparameter("@age", sqldbtype.int) { .value = 18}, new sqlparameter("@id", sqldbtype.int) { .value = 123} }
Comments
Post a Comment