您现在的位置: 主页 > 上位机技术 > Unity3D > unity3d怎么连接sql server数据库?
本文所属标签:
为本文创立个标签吧:

unity3d怎么连接sql server数据库?

来源:网络整理 网络用户发布,如有版权联系网管删除 2018-08-16 

   1、找到System.Data.dll文件,默认的地址是在C:Program FilesUnityEditorDataMonolibmonounity,这个根据你所安装的路径有关。

unity3d怎么连接sql server数据库? 三联

  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、实验结果



              查看评论 回复



嵌入式交流网主页 > 上位机技术 > Unity3D > unity3d怎么连接sql server数据库?
 你的 代码 程序

"unity3d怎么连接sql server数据库?"的相关文章

网站地图

围观()