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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -