C#实现人脸识别【SqlHelper】
生活随笔
收集整理的這篇文章主要介紹了
C#实现人脸识别【SqlHelper】
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
操作數據庫工具類:
using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Data.SqlClient; using System.Configuration; using System.Data;namespace face {/// <summary>/// 數據庫工具類/// </summary>public class SqlHelper{#region 獲取數據庫連接private static string GetConnectionString{get{return "Data Source=.;Initial Catalog=TestFaceDB;Persist Security Info=True;User ID=sa;Password=171268"; //轉換成string類型}}#endregion#region 查詢多條記錄/// <summary>/// 查詢多條記錄/// params SqlParameter param 表示既可以傳過來數組 也可以傳過來單個值/// </summary>/// <param name="sql"></param>/// <param name="type"></param>/// <param name="param"></param>/// <returns></returns>public static SqlDataReader ExcuteReader(string sql, CommandType type, params SqlParameter[] param){SqlConnection conn = new SqlConnection(GetConnectionString);SqlCommand cmd = new SqlCommand(sql, conn);PreaPareCommand(sql, conn, cmd, type, param);//參數是關閉連接return cmd.ExecuteReader(CommandBehavior.CloseConnection);}#endregion#region DataSetpublic static DataSet ExexuteDataset(string sql, CommandType type, params SqlParameter[] param){using (SqlConnection conn = new SqlConnection(GetConnectionString)){SqlCommand cmd = new SqlCommand(sql, conn);PreaPareCommand(sql, conn, cmd, type, param);SqlDataAdapter sda = new SqlDataAdapter(cmd);DataSet ds = new DataSet();sda.Fill(ds);return ds;}}#endregion#region 查詢返回一條記錄/// <summary>/// 查詢返回一條記錄/// </summary>/// <param name="sql"></param>/// <param name="type"></param>/// <param name="param"></param>/// <returns></returns>public static Object ExecuteScalar(string sql, CommandType type, params SqlParameter[] param){using (SqlConnection conn = new SqlConnection(GetConnectionString)){SqlCommand cmd = new SqlCommand(sql, conn);PreaPareCommand(sql, conn, cmd, type, param);return cmd.ExecuteScalar();}}#endregion#region 命令對象裝配//命令對象裝配private static void PreaPareCommand(string sql, SqlConnection conn, SqlCommand cmd, CommandType type, params SqlParameter[] param){if (conn.State != ConnectionState.Open){conn.Close();conn.Open();}cmd.CommandType = type;if (param != null){foreach (SqlParameter p in param){cmd.Parameters.Add(p);}}}#endregion#region 增刪改public static int ExecuteNonQuery(string sql, CommandType type, params SqlParameter[] param){using (SqlConnection conn = new SqlConnection(GetConnectionString)){SqlCommand cmd = new SqlCommand(sql, conn);PreaPareCommand(sql, conn, cmd, type, param);return cmd.ExecuteNonQuery();}}#endregion} }總結
以上是生活随笔為你收集整理的C#实现人脸识别【SqlHelper】的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 骑马与砍杀战团攻略 骑马与砍杀战团新手攻
- 下一篇: 饭圈五阿哥 饭圈五阿哥是谁