c# - FUNCTION not returning required value -
i have created class library generates number everytime use in other windows application , number gets updated everytime use it.
public int generate_num(string p_prm_type) { try { int v_last_no = 0; string query = @"select parm_value soc_parm_mast parm_type = '" + p_prm_type + "';"; command.commandtext = query; oledbdatareader reader = command.executereader(); reader.read(); v_last_no = int32.parse(reader["parm_value"].tostring()) + 1; reader.close(); command.commandtext = @"update soc_parm_mast set parm_value = parm_value+1 parm_type = " + p_prm_type + ";"; command.executenonquery(); return v_last_no; } catch(exception exception) { return 404; } }
i using class in other windows form application generate new no. everytime call it.but not working , returning 404.
int vtrans_no = gen_no.generate_num("tran");
there missing quotes on second query, p_prm_type
string need put ' '
:
command.commandtext = @"update soc_parm_mast set parm_value = parm_value+1 parm_type = '" + p_prm_type + "';"
Comments
Post a Comment