欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 运维知识 > 数据库 >内容正文

数据库

Mysql雨松工具类使用

发布时间:2024/9/30 数据库 42 豆豆
生活随笔 收集整理的这篇文章主要介绍了 Mysql雨松工具类使用 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

资源窗口视图

脚本:

场景例子

普通增删改查例子

Mysql核心工具类

 

 

  • 导入dll文件。
  • 导入脚本SqlAccess
  • 使用
  •  

    主要功能

     

     

    创建表

    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雨松工具类使用的全部内容,希望文章能够帮你解决所遇到的问题。

    如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。