c# - I want to Insert RadioButton Value in SQL Database using Classes -
i created class name employeedata write code here , want insert radiobutton value in sql database
public static void addemployee(employee employee) { string connstring = configurationmanager.connectionstrings["employee"].connectionstring; sqlconnection conn = new sqlconnection(connstring); using (conn) { sqlcommand cmd = new sqlcommand("addemployee", conn); cmd.commandtype = commandtype.storedprocedure; cmd.parameters.add("@name", sqldbtype.nvarchar, 50).value = employee.name; cmd.parameters.add("@fname", sqldbtype.nvarchar, 50).value = employee.fname; cmd.parameters.add("@address", sqldbtype.nvarchar, 50).value = employee.address; cmd.parameters.add("@email", sqldbtype.nvarchar, 50).value = employee.email; cmd.parameters.add("@mobile", sqldbtype.nvarchar, 50).value = employee.mobile; cmd.parameters.add("@pincode", sqldbtype.nvarchar, 50).value = employee.pincode; cmd.parameters.addwithvalue("@vb", sqldbtype.bit).value = employee.vb; cmd.parameters.addwithvalue("@asp", sqldbtype.bit).value = employee.asp; cmd.parameters.addwithvalue("@gender", sqldbtype.int).value = employee.gender; conn.open(); cmd.executenonquery(); } }
add parameter stored procedure call:
cmd.parameters.addwithvalue("@valueofradiobuttonr", sqldbtype.int).value = myradiobutton.value;
in stored procedure on database, make sure handle parameter.
Comments
Post a Comment