Anda di halaman 1dari 1

sqlconnection con = new sqlconnection(configurationsettings.

appsettings["con"]);
con.open();
sqlcommand cmd = new sqlcommand();
cmd.connection = con;

cmd.commandtext = "product_insert";
cmd.commandtype = commandtype.storedprocedure;
sqlparameter p1, p2, p3, p4, p5, p6, p7;

p1 = cmd.parameters.add("@productid", sqldbtype.varchar);
p1.direction = parameterdirection.input;
p1.value = textbox1.text;

p2 = cmd.parameters.add("@productname", sqldbtype.varchar);
p2.direction = parameterdirection.input;
p2.value = textbox2.text;

p3 = cmd.parameters.add("@price", sqldbtype.varchar);
p3.direction = parameterdirection.input;
p3.value = textbox3.text;

p5 = cmd.parameters.add("@pdescription", sqldbtype.varchar);
p5.direction = parameterdirection.input;
p5.value = textbox5.text;

p4 = cmd.parameters.add("@category", sqldbtype.varchar);
p4.direction = parameterdirection.input;
p4.value = dropdownlist1.text;

p6 = cmd.parameters.add("@image1", sqldbtype.varchar);
p6.direction = parameterdirection.input;
p6.value = textbox6.text;

p7 = cmd.parameters.add("@imagepath", sqldbtype.varchar);
p7.direction = parameterdirection.input;
p7.value = textbox4.text;

cmd.executenonquery();