【发布时间】:2022-01-06 14:28:01
【问题描述】:
private int getuserid(String username){
SqlConnection con = new SqlConnection(_conString);
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SELECT USER_ID from tblUser where USERNAME ='" +username+"'";
int locid = Convert.ToInt32(cmd.CommandText);
return locid;
}
大家好,您知道如何在变量中分配 user_id 的值并返回它。我试过了,但我不确定它好不好。
【问题讨论】:
-
哎呀,这看起来很可怕——容易受到 sql 注入问题的影响。
标签: mysql asp.net sql-server database web