Mysql雨松工具类使用
资源窗口视图
脚本:
场景例子
普通增删改查例子
Mysql核心工具类
主要功能
创建表
private void CreateTable()
{
SqlAccess sql = new SqlAccess();
sql.CreateTable("Infomation", new string[] { "name", "id", "password" }, new string[] { "text", "int", "text" });
sql.Close();
}
插入数据
private void Insert()
{
SqlAccess sql = new SqlAccess();
sql.InsertInto("login", new string[] {"name","id","password" },new string[] {"456","2","456" });
sql.Close();
}
删除数据
private void Delete()
{
SqlAccess sql = new SqlAccess();
sql.Delete("login", new string[] {"id"}, new string[] {"2"});
sql.Close();
}
更新数据
private void UpdateInfo()
{
SqlAccess sql = new SqlAccess();
sql.UpdateInto("login", new string[] { "name", "id", "password" }, new string[] { "789", "789", "789" }, "id", "1");
sql.Close();
}
查找数据
private void Select()
{
SqlAccess sql = new SqlAccess();
DataSet ds = sql.SelectWhere("login", new string[] { "name", "password" }, new string[] { "id" }, new string[] { "=" }, new string[] { "1" });
if (ds != null)
{
DataTable table = ds.Tables[0];
foreach (DataRow row in table.Rows)
{
foreach (DataColumn column in table.Columns)
{
print(row[column]);
}
}
}
sql.Close();
}
private void SelectOne()
{
SqlAccess sql = new SqlAccess();
DataSet ds = sql.SelectWhere("login", new string[] { "name", "password" }, new string[] { "name" }, new string[] { "=" }, new string[] { "123" });
if (ds != null)
{
DataTable table = ds.Tables[0];
string str = table.Rows[0][table.Columns[1]].ToString();
}
sql.Close();
}
数据库表中结构图
源地址:http://www.xuanyusong.com/archives/2326。
总结
以上是生活随笔为你收集整理的Mysql雨松工具类使用的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: SteamVR 工具包VRTK实例解析
- 下一篇: MySQL本人工具使用