unity3d安装教程连接ACCESS

当前位置: >
猜你也喜欢看这些 ??????
其他类型的源码下载 ??????Navigation
Unity Account
You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio.
Pre-order Unity 5 and get Unity 4 today!
Log in to see if you qualify for Unity 5 upgrade discounts
Enter rebate/voucher code
{:not_found=&&Code not found&, :not_your_code=&&Please sign in to the account, that this voucher was issued to&}
The full professional suite of tools and rendering power from Unity. Create polished and high-performing 2D and 3D games and interactive content for multiplatform deployment.
Add-ons for Unity Pro
You must first select
before choosing additional deployment products.
Please select
first if you want to purchase a Team License together with Unity Pro. You can also select a
on its own, however, the free version of Unity is included in the purchase.
Have an existing license that you want to upgrade?
Upgrade your existing license starting from $750. To upgrade or add additional features to an existing license, .
The key details
A subscription runs for a minimum of 12 months and is available via the Online Store.
There is a limit of 3 subscription plans per customer account.
You do not own the Unity Pro license. If you choose to end your subscription after 12 months, your Unity Pro license will revert to the free version of Unity.
A subscription to Unity Pro costs $75/month. Each Pro add-on also costs $75/month.
Everyone can subscribe. If you are already a customer, you can start a separate subscription plan alongside your perpetual license.
You own any content that you create with a Unity Pro subscription.
You are committed to paying all monthly payments in a 12 month plan.
Modifying a subscription plan
Managing your subscription
Excluding VAT
* American Express and Paypal are not valid for subscription. If you are paying with American Express you must
About Unity
Get Unity news
I agree to the
and the processing and use of my information
Nearly there...
To start receiving news from Unity Technologies, click on the link we've sent to your e-mail account.
Something went wrong, please try again.
Copyright & 2015 Unity Technologies只需一步,快速开始
只需一步,快速开始
访问Access数据库
已有 249 次阅读 14:36
|个人分类:|
Access数据库呢,是一个轻量级的数据库,以前在学习.net应用开发的时候了解过。在pc的软件开发中,很多时候,我们存储的数据量不会很大的情况都会选择他,主要他轻量级,容易部署。更多Access的问题,可以去微软的官网查看。
在U3D中要访问Access数据库,我们需要用到两个dll,System.Data.dll和System.EnterpriseServices.dll,缺一不可。我们找到这两个dll放到u3d的Plugins文件夹下面。
下面我们创建一个Access数据库版本是07样式是*.accdb(03版本的Access数据库的样式为*.mdb)在我们进行code的时候,要根
据不同的版本进行判断啦,对于不同的Access数据库版本,我们要对应不懂的文件后缀名。要不然会提示你数据库文件是未知文件。
下面是读取Access的一个demo,其他的修改,添加数据都是在修改他的sql语句啦,相关的知识,可以查看Access在.net中如何对Access进行CURD操作的。简单的代码如下:
/* |-------------------------------------------
* |作者:Mr.野猪
* |时间:&&晚:23:56
* |目的:用于技术交流
* |------------------------------------------
using UnityE
using System.C
//引入命名空间
using System.D
using System.Data.O
public class RaderData : MonoBehaviour
/// &summary&
/// 声明一个接受读取数据字段值的变量
/// &/summary&
string text = string.E
public void Start()
//读取数据文件。
ReadStudent(Application.dataPath + "/Wild boar.accdb");
/// &summary&
/// 读取表数值的函数
/// &/summary&
/// &param name="filetoread"&数据文件的路径&/param&
internal void ReadStudent(string filetoread)
//声明连接数据库的字段
string connection = "Driver={Microsoft Access Driver (*.mdb, *.accdb)}; DBQ=" +
//从表中查询所有数据
string sqlQuery = "select * from Student";
//打开数据库
OdbcConnection con = new OdbcConnection(connection);
//对数据库进行操作
OdbcCommand cmd = new OdbcCommand(sqlQuery,con);
//根据表名,读取数据到一个临时表
DataTable dt = new DataTable("Student");
//try catch finally进行了异常处理,这个是好习惯,嘿嘿
//打开数据库
con.Open();
//读取数据
OdbcDataReader reader = cmd.ExecuteReader();
//把数据加载到临时表
dt.Load(reader);
//在使用完毕之后,一定要关闭,要不然会出问题
reader.Close();
//关闭数据库
con.Close();
catch (Exception ex)
Debug.Log(ex.ToString());
//判断数据库是否打开,如果打开就关闭。
if (con.State!=ConnectionState.Closed)
con.Close();
//释放数据库资源
con.Dispose();
if (dt.Rows.Count&0)
//读取数据
for (int i = 0; i & dt.Rows.C i++)
text = dt.Columns[0].ColumnName + " : " +
dt.Rows[dt.Columns[0].ColumnName].ToString() + "&&|&&" +
dt.Columns[1].ColumnName + " : " +
dt.Rows[dt.Columns[1].ColumnName].ToString() + "&&|&&" +
dt.Columns[2].ColumnName + " : " +
dt.Rows[dt.Columns[2].ColumnName].ToString() + "&&|&&" +
dt.Columns[3].ColumnName + " : " +
dt.Rows[dt.Columns[3].ColumnName].ToString();
Debug.Log(dt.Columns[0].ColumnName + " : " +
dt.Rows[dt.Columns[0].ColumnName].ToString() + "&&|&&" +
dt.Columns[1].ColumnName + " : " +
dt.Rows[dt.Columns[1].ColumnName].ToString() + "&&|&&" +
dt.Columns[2].ColumnName + " : " +
dt.Rows[dt.Columns[2].ColumnName].ToString() + "&&|&&" +
dt.Columns[3].ColumnName + " : " +
dt.Rows[dt.Columns[3].ColumnName].ToString());
public void OnGUI()
GUI.Label(new Rect(10,10,500,200),text);
下一步,我们生成exe文件.执行完毕之后,我们打开生成的程序截图如下:
为什么会出现这个问题。我在u3d里面看到了他的显示啊,如下:
其实呢,我们在部署的时候,要把数据库文件,copy到生成的文件夹下就可以啦!
再次运行程序,查看效果。如下:
好,看到这里,你应该只到了,我今天重点要说的就是这个问题啦!
下面是我在制作demo时,遇到的问题还有些是我特意测试需要注意的地方:
1. 一定要记住的是,访问Access数据库时,那两个dll缺一不可,缺少就会出现问题。
2. 在带有dll动态链接库的项目,要在打包时设置他的API兼容层级为.NET 2.0。
3. 使用不同版本的Access数据库要对应不同版本相对应的后缀名。
4. 如果想单独创建一个存放Access数据库的文件夹,你需要在code时,找到这个文件夹,然后打包之后,把你的Access数据库放到与code相对应的位置。要不然,检测不到数据库。
5. 在创建数据库时要认真,嘿嘿,有可能是你的文件名字和后缀名之间多个空格,你的数据也会读不出,在u3d中运行,会提示你未知文件。
6. 就是老生常谈的话题了,sql查询语句一定要记住,拼写正确,标点符号也要对应起来,要不然,出现个小问题,会让你DT好久。曾经在做应用时,也DT过。
原文链接:
作者的其他最新日志
评论 ( 个评论)
会员每日登陆可获得鲜花+1、下载币+1、U币+1
希望大家积极发帖共建unity联盟!当前位置: >
猜你也喜欢看这些 ??????
其他类型的源码下载 ??????热门搜索:
您当前位置: >>
>> 浏览文章
Unity3D怎样读取Access数据库?
日期: 17:13:07 来源:酷驰科技
在U3D中要访问Access数据库,我们需要用到两个dll,System.Data.dll和System.EnterpriseServices.dll,缺一不可。我们找到这两个dll放到u3d的Plugins文件夹下面。
下面我们创建一个Access数据库版本是07样式是*.accdb(03版本的Access数据库的样式为*.mdb)在我们进行code的时候,要根据不同的版本进行判断啦,对于不同的Access数据库版本,我们要对应不懂的文件后缀名。要不然会提示你数据库文件是未知文件。
下面是读取Access的一个demo,其他的修改,添加数据都是在修改他的sql语句啦。简单的代码如下:
using UnityE
using System.C
//引入命名空间
using System.D
using System.Data.O
public class RaderData : MonoBehaviour
/// &summary&
/// 声明一个接受读取数据字段值的变量
/// &/summary&
string text = string.E
public void Start()
//读取数据文件。
ReadStudent(Application.dataPath + &/Wild boar.accdb&);
/// &summary&
/// 读取表数值的函数
/// &/summary&
/// &param name=&filetoread&&数据文件的路径&/param&
internal void ReadStudent(string filetoread)
//声明连接数据库的字段
string connection = &Driver={Microsoft Access Driver (*.mdb, *.accdb)}; DBQ=& +
//从表中查询所有数据
string sqlQuery = &select * from Student&;
//打开数据库
OdbcConnection con = new OdbcConnection(connection);
//对数据库进行操作
OdbcCommand cmd = new OdbcCommand(sqlQuery,con);
//根据表名,读取数据到一个临时表
DataTable dt = new DataTable(&Student&);
//try catch finally进行了异常处理,这个是好习惯,嘿嘿
//打开数据库
con.Open();
//读取数据
OdbcDataReader reader = cmd.ExecuteReader();
//把数据加载到临时表
dt.Load(reader);
//在使用完毕之后,一定要关闭,要不然会出问题
reader.Close();
//关闭数据库
con.Close();
catch (Exception ex)
Debug.Log(ex.ToString());
//判断数据库是否打开,如果打开就关闭。
if (con.State!=ConnectionState.Closed)
con.Close();
//释放数据库资源
con.Dispose();
if (dt.Rows.Count&0)
//读取数据
for (int i = 0; i & dt.Rows.C i++)
text = dt.Columns[0].ColumnName + & : & + dt.Rows[dt.Columns[0].ColumnName].ToString() + && |& & + dt.Columns[1].ColumnName + & : & + dt.Rows[dt.Columns[1].ColumnName].ToString() + && |& & + dt.Columns[2].ColumnName + & : & + dt.Rows[dt.Columns[2].ColumnName].ToString() + && |& & + dt.Columns[3].ColumnName + & : & + dt.Rows[dt.Columns[3].ColumnName].ToString();
Debug.Log(dt.Columns[0].ColumnName + & : & + dt.Rows[dt.Columns[0].ColumnName].ToString() + && |& & + dt.Columns[1].ColumnName + & : & + dt.Rows[dt.Columns[1].ColumnName].ToString() + && |& & + dt.Columns[2].ColumnName + & : & + dt.Rows[dt.Columns[2].ColumnName].ToString() + && |& & + dt.Columns[3].ColumnName + & : & + dt.Rows[dt.Columns[3].ColumnName].ToString());
public void OnGUI()
GUI.Label(new Rect(10,10,500,200),text);
【】【】【】【】【】}

我要回帖

更多关于 unity3d下载 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信