SQL封装库学习笔记1.0

自用学习写的封装库

使用方法:Nuget中搜索HNGYSql

using SqlLibraries;

使用实例对象SqlUser

1.查询数据方法

public string CommandSelect(string connectionString, string commandString)

connectionString: 所连接的数据库对象

commandString: 所执行的查询语句

作用:执行查询语句

返回值为所查询的结果(有多的空行,使用返回结果时注意切割字符串)

使用完自动释放,无需close

查询支持数据类型如下,如需其它类型请手动添加

1.1.0版本追加了date类型

 

 

 

Eg:

connectionString ="server=.;database=电影售票系统;uid=ojl;pwd=123456";

//.表示为本地连接,database对应数据库名,uid和pwd对应登录数据库的账号和密码

commandString= "select * from table_customer";

 

结果:返回table_customer表的所有数据

 

2.通用执行命令方法(增删改)

public bool CommandGeneral(string connectionString, string commandString)

connectionString: 所连接的数据库对象

commandString: 所执行的命令语句

作用:执行功能语句

返回值为执行命令是否成功

使用完自动释放,无需close

 

3.关闭连接方法(已废弃)

public bool Close()

posted @ 2022-10-13 14:14  SharpThreed  阅读(256)  评论(0编辑  收藏  举报