首页 > 代码库 > .NET MySQL的参数化查询
.NET MySQL的参数化查询
MySqlConnection conn = new MySqlConnection(SqlConnnectString);MySqlCommand cmd = new MySqlCommand("SELECT * FROM `TB_CM_Log` WHERE ID = ?ID LIMIT 1", conn);cmd.Parameters.AddWithValue("ID", id);cmd.CommandType = CommandType.Text;cmd.Parameters.Clear();TB_CM_Log model = new TB_CM_Log();if (conn.State != ConnectionState.Open) conn.Open();using (MySqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection){ while (dr.Read()) { model.ID = dr.GetString(0); model.ModType = dr.GetInt32(1); model.ModTypeName = dr.GetString(2); model.SourcesType = dr.GetString(3); model.Description = dr.GetString(4); model.OperatorID = dr.GetInt32(5); model.OperatorName = dr.GetString(6); model.SucFlag = dr.GetInt32(7); model.OperaTime = dr.GetDateTime(8); model.IP = dr.IsDBNull(9) ? "" : dr.GetString(9); model.ResultDes = dr.IsDBNull(10) ? "" : dr.GetString(10); }}conn.Close();
.NET MySQL的参数化查询
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。