系统之家 - Windows操作系统&装机软件下载网站!

当前位置: 首页  >  教程资讯  >  电脑教程 unity3d怎么连接sql server数据库?

unity3d怎么连接sql server数据库?

时间:2023-06-02 16:16:41 来源: 人气:

   1、找到System.Data.dll文件,默认的地址是在C:Program FilesUnityEditorDataMonolibmonounity,这个根据你所安装的路径有关。,  2、将该文件复制到你的工作空间下的Asset文件夹内,  3、在你的编辑器中添加引用,我用的是VS,  4、在命名空间内增加程序集,  using System;,  using System.Data;,  using System.Data.SqlClient;,  5、编写连接数据库代码,  SqlConnection con = null;,  SqlDataAdapter sda = null;,  void Start(),  {,  string s = @"server=.;database=ConnectTest;uid=sa;pwd=123456"; //注意,这里必须使用SQL Server和Windows验证模式,否则会报错,  con = new SqlConnection(s);,  con.Open();,  string sql = "select * from table1";,  sda = new SqlDataAdapter(sql, con);,  DataSet ds = new DataSet();,  sda.Fill(ds, "table1");,  print(ds.Tables[0].Rows[0][0]);,  },  6、实验结果,

作者

教程资讯

电脑教程排行

系统教程

系统主题