沈阳微信网站建设网站建设销售方面会遇到的问题
news/
2025/9/23 23:33:35/
文章来源:
沈阳微信网站建设,网站建设销售方面会遇到的问题,绍兴集团网站建设,邢台中高风险地区数据存储量比较大时#xff0c;我就需要将数据存储在数据库中方便使用#xff0c;尤其是制作管理系统时#xff0c;它的用处就更大了。 在编写程序前#xff0c;需要在Assets文件夹中创建plugins文件#xff0c;将.dll文件导入#xff0c;文件从百度网盘自取#xff1a;…数据存储量比较大时我就需要将数据存储在数据库中方便使用尤其是制作管理系统时它的用处就更大了。 在编写程序前需要在Assets文件夹中创建plugins文件将.dll文件导入文件从百度网盘自取 链接https://pan.baidu.com/s/1N4xlkh9FP28d8lHylcNe4g 提取码5zap
连接数据库代码如下
using UnityEngine;
using MySql.Data.MySqlClient;public string ConnectStr;
public MySqlConnection conn;void Start()
{ConnectStr “Server 192.168.1.25;Database student;User ID root;Password 123456;Port 8086;charset utf8”;//数据库所在电脑的IP地址数据库名称数据库用户名用户密码数据库端口号采用的编码格式conn new MySqlConnection(ConnectStr);
}在表中新增信息
void add()
{conn.Open();string insertInfo insert into user(account_id,account_type,password,name)values(0,0,123456,ling)MysqlCommand insert new MySqlCommand(insertInfo,conn);insert.ExecuteNonQuery();conn.Close();
}如果插入的值为变量则需将插入语句换为如下
string insertInfo insert into user(account_id,account_type,password,name)values( accountId , accountType ,123456,ling);//其他类似将表中信息删除
void delete()
{conn.Open();string deleteInfo delete from user where account_id accountId MysqlCommand delete new MySqlCommand(deleteInfo,conn);delete.ExecuteNonQuery();conn.Close();
}将表中信息修改
void update()
{conn.Open();string updateInfo update user set account_type accountType where account_id accountId MysqlCommand update new MySqlCommand(updateInfo,conn);update.ExecuteNonQuery();conn.Close();
}将表中信息查询
void search()
{conn.Open();string searchInfo select *from user where account_id accountId //查询id号为accountId 的所有信息MysqlCommand search new MySqlCommand(searchInfo,conn);MysqlDataReader reader search.ExecuteReader();if(reader.Read()){string account_id reader[0];string account_type reader[1];string password reader[2];string name reader[3];}conn.Close();
}
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/914241.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!