Mysql雨松工具类使用

资源窗口视图

脚本:

场景例子

普通增删改查例子

Mysql核心工具类

 

 

  1. 导入dll文件。
  2. 导入脚本SqlAccess
  3. 使用

 

主要功能

 

 

创建表

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

猜你喜欢

转载自blog.csdn.net/qq_25601345/article/details/78499523