Unity 连接SQL Server 数据库及接受测试

来源:互联网 发布:socket io 知乎 编辑:程序博客网 时间:2024/06/06 14:04
using UnityEngine;using System.Collections;using System.Data.SqlClient;using System.Data;public class SQLTest : MonoBehaviour {        SqlConnection con = null;    SqlDataAdapter sda = null;    // Use this for initialization    void Start () {        string s = @"Server=192.168.1.116;Initial Catalog=Test;User ID=sa;Password=123";        con = new SqlConnection(s);        con.Open();        print(con.StatisticsEnabled);        string sql = "select * from Table_1";        sda = new SqlDataAdapter(sql, con);        DataSet ds = new DataSet();        sda.Fill(ds, "Table_1");        print(ds.Tables[0].Rows[0][0]);    }   }