找回密码
 立即注册
查看: 4308|回复: 63

[脚本] 在Unity3D实现增删改查

[复制链接]
发表于 2013-2-27 09:40 | 显示全部楼层 |阅读模式
增 删 查 代 码 如 下 :
  1. using UnityEngine;
  2. using System.Collections;
  3. using System;
  4. //using System.Data.SqlClient;

  5. public class sqlconnect : MonoBehaviour {

  6.         public string tempip;
  7.         //public string user="user_";
  8.         // Use this for initialization
  9.         void Start () {
  10.         System.Data.SqlClient.SqlConnection sqlcon = new System.Data.SqlClient.SqlConnection("Data Source=Sql1001.webweb.com,2433;Initial Catalog=DB_98CEEF_test;User Id=DB_98CEEF_test_admin;Password=testtest");
  11.         sqlcon.Open();
  12.         //string str = "select * from user_";
  13.         //string str = "insert into test values ('domino','jinan')";   
  14.         string str = "delete  from test where test_name ='domino'";   
  15.         System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(str,sqlcon);
  16.         
  17.             if((int)cmd.ExecuteNonQuery() > 0)
  18.             {
  19.                   tempip = "ok";
  20.             }
  21.             else
  22.             {
  23.                    tempip = "error";
  24.             }
  25.         sqlcon.Close();
  26.         
  27.         }
  28.         void OnGUI()
  29.         {
  30.                 GUILayout.Label(tempip);
  31.                 }
  32.         // Update is called once per frame
  33.         void Update () {
  34.         
  35.         }
  36. }
复制代码
无论在哪发布
一定要注意1.//using System.Data.SqlClient;
什么时候使用,什么时候调用。不要放到using里面。
2 将l8开头的一堆文件倒入到Asset中。


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
发表于 2013-2-27 09:54 | 显示全部楼层
unity3d中 使用 C# script 与mysql进行通讯,在引擎中运行可以通讯,读取写入,可是发布webplay 或发布为EXE文件运行时就无法进行通讯?
答:
将Unity3d的安装目录下面的I18N.CJK.dll,I18N.dll,I18N.West.dll,放入工程文件夹Asset下面

点评

Joy
亲,能否把这几个Dll文件打包共享一下?  详情 回复 发表于 2013-2-28 17:10
发表于 2013-2-28 17:10 | 显示全部楼层
强子 发表于 2013-2-27 09:54
unity3d中 使用 C# script 与mysql进行通讯,在引擎中运行可以通讯,读取写入,可是发布webplay 或发布为EX ...

亲,能否把这几个Dll文件打包共享一下?
发表于 2013-4-12 13:11 | 显示全部楼层
放在webplay 上也可以吗?
发表于 2017-6-16 20:48 | 显示全部楼层
好帖就是要顶
发表于 2017-6-16 21:28 | 显示全部楼层
真心顶
发表于 2017-6-16 21:26 | 显示全部楼层
难得一见的好帖
发表于 2017-6-16 21:11 | 显示全部楼层
说的非常好
发表于 2017-6-16 20:48 | 显示全部楼层
LZ真是人才
发表于 2017-6-26 18:45 | 显示全部楼层
很不错
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Unity开发者联盟 ( 粤ICP备20003399号 )

GMT+8, 2024-5-3 18:33 , Processed in 0.129174 second(s), 29 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表