当前位置:网站首页>Unity 连接 Microsoft SQLSERVER 数据库
Unity 连接 Microsoft SQLSERVER 数据库
2022-06-12 11:12:00 【游戏编程】
1. 配置Unity环境
- Unity Editor 设置Unity框架兼容性至4.X 在编辑器中,您需要打开播放器设置(文件->构建设置->播放器设置)。 然后,在其他设置下,您可以找到运行时和API级别

2.添加ddl
Unity安装路径下查找需要的ddl,复制到项目的Assets文件夹下D:\unity\2020.3.8f1c1\Editor\Data\MonoBleedingEdge\lib\mono\4.7-api

复制到项目文件夹下

2.连接数据库脚本编写
- 引用using System.Data.SqlClient;命名空间
- 编写脚本
void Start() { SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(); builder.DataSource = "localhost"; // update me builder.UserID = "sa"; // update me builder.Password = "123456"; // update me builder.InitialCatalog = "db_example"; string res = ""; try { using (SqlConnection connection = new SqlConnection(builder.ConnectionString)) { connection.Open(); // READ demo string sqlStr = "select * FROM [db_example].[dbo].[tb_user];"; using (SqlCommand command = new SqlCommand(sqlStr, connection)) { using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { res = reader.GetInt32(0).ToString(); } } } } } catch (SqlException e) { Debug.Log(e.ToString()); } Debug.Log(res); }3. 配置数据库
- 数据库安全配置允许用户名密码远程连接
登录名状态设置
数据库服务的TCP/IP服务开启
重启SQLSERVER服务
游戏编程,一个游戏开发收藏夹~
如果图片长时间未显示,请使用Chrome内核浏览器。
边栏推荐
- B+ 树的简单认识
- AcWing 128. 编辑器(对顶栈 实现序列内部指定位置高效修改)
- Index query efficiency of MySQL
- JS obtains the time period of this week and last week (one time period is from Monday to Sunday)
- 模块8作业
- (三十七)Bee如何同时使用不同数据源实例
- This and final keywords
- Immer source code reading
- AcWing 135. Maximum subsequence sum (prefix sum + monotone queue to find the minimum value of fixed length interval)
- Mysql5.6.24 installation free deployment method
猜你喜欢
随机推荐
^34 scope interview questions
A simple understanding of b+ tree
Immer source code reading
Using the echart plug-in to dynamically refresh charts in uview/uni-app
k58.第一章 基于kubeadm安装kubernetes v1.23 -- 集群部署
FPGA开发——Hello_world例程
Reading mysql45 lecture - self summary (part)
Valentina Studio Pro for MAC (MAC database management software)
AcWing 135. Maximum subsequence sum (prefix sum + monotone queue to find the minimum value of fixed length interval)
Why check the @nonnull annotation at run time- Why @Nonnull annotation checked at runtime?
^34作用域面试题
力扣(LeetCode)162. 寻找峰值(2022.06.11)
Amélioration de la 3dsc par HSC
selenium使用代理IP
ReentrantLock源码分析
On the improvement of 3dsc by harmonic shape context feature HSC
Bug easily ignored by recursion
Common tools download address
MATLAB中stairs函数使用
模块8作业








