NullReferenceException: Object reference not set to an instance of an Object
Mono. Data. Tds. Protocol. Tds70. Connect (Mono) Data) Tds. Protocol. TdsConnectionParameters connectionParameters)
Mono. Data. Tds. Protocol. Tds80. Connect (Mono) Data) Tds. Protocol. TdsConnectionParameters connectionParameters)
System. The Data. SqlClient. SqlConnection. The Open ()
NullReferenceException: Object reference not set to an instance of an Object
Mono. Data. Tds. Protocol. TdsConnectionPool. GetConnection ()
System. The Data. SqlClient. SqlConnection. The Open ()
System.Data.Com mon. DbDataAdapter. The Fill (System. Data. The DataSet DataSet, Int32 startRecord, Int32 maxRecords, System. String srcTable, IDbCommand command, CommandBehavior behaviors)
System.Data.Com mon. DbDataAdapter. The Fill (System. Data. The DataSet DataSet)
Tirger. Say () (at Assets/Scripts/Tirger cs: 100)
Tirger. Start () (at Assets/Scripts/Tirger cs: 91)
The code is as follows:
String con=@ "Password=sa; Persist Security Info=True; User ID=sa; Initial Catalog=SmelterDB_Tar; Data Source=222.222.115.11 ";
SqlConnection sc=new SqlConnection (con);
Sc. The Open ();
String SQL="select top 10 * from entity_70003";
SqlDataAdapter sda=new SqlDataAdapter (SQL, sc);
The DataSet ds=new DataSet ();
Sda. The Fill (ds);
DataTable dt=ds.Tables[0];
Foreach (DataRow row in dt. Rows)
{
Foreach (DataColumn column in dt. The Columns)
{print (row (column)); }
}
Sc. The Close ();
CodePudding user response:
Suggested to set up a server to get the db data, although unity3d claims in c # development, but the underlying or by some changes, can not direct connect databaseCodePudding user response: