Exemplo n.º 1
0
 /// <summary>
 /// 查询第一行第一列数据(有参)(返回的是什么类型就转换成什么类型)
 /// </summary>
 /// <param name="values">参数</param>
 /// <returns>object</returns>
 public static object GetScalar(string safeSql, params MySQLDriverCS.MySQLParameter[] values)
 {
     MySQLDriverCS.MySQLCommand cmd = new MySQLDriverCS.MySQLCommand(safeSql, Connection);
     cmd.Parameters.AddRange(values);
     return(cmd.ExecuteScalar());
 }
Exemplo n.º 2
0
 /// <summary>
 /// 返回string
 /// </summary>
 /// <param name="sql"></param>
 /// <param name="values"></param>
 /// <returns></returns>
 public static string GetScalarString(string sql, params MySQLDriverCS.MySQLParameter[] values)
 {
     MySQLDriverCS.MySQLCommand cmd = new MySQLDriverCS.MySQLCommand(sql, Connection);
     cmd.Parameters.AddRange(values);
     return(Convert.ToString(cmd.ExecuteScalar()));
 }
Exemplo n.º 3
0
 /// <summary>
 /// 查询第一行第一列数据(无参)(返回的是什么类型就转换成什么类型)
 /// </summary>
 /// <param name="safeSql">语句</param>
 /// <returns>object</returns>
 public static object GetScalar(string safeSql)
 {
     MySQLDriverCS.MySQLCommand cmd = new MySQLDriverCS.MySQLCommand(safeSql, Connection);
     return(cmd.ExecuteScalar());
 }