Reputation: 672
I am trying to connect to MS SQL database. Here is my code:
void Start ()
{
string connectionString =
"Server=MyServer;" +
"Database=Data;" +
"User ID=User;" +
"Password=psd;" +
"Integrated Security=SSPI";
Debug.Log("conn string");
List<int> result = new List<int>();
string sql = "SELECT RecordCount FROM MainDB";
IDbConnection dbcon;
dbcon = new SqlConnection (connectionString);
dbcon.Open ();
IDbCommand dbcmd = dbcon.CreateCommand ();
dbcmd.CommandText = sql;
IDataReader rdr = dbcmd.ExecuteReader ();
while (rdr.Read()) {
result.Add ((int)rdr.GetValue(0));
}
Debug.Log("get");
// clean up
rdr.Close ();
rdr = null;
dbcmd.Dispose ();
dbcmd = null;
dbcon.Close ();
dbcon = null;
}
I copyed most of code from mono-project. I allowed UDP port 1434 and mono.exe in my firewall rules. And Iam still getting message:
NotImplementedException: Mono does not support names pipes or shared memory for connecting to SQL Server. Please enable the TCP/IP protocol. System.Data.SqlClient.SqlConnection+SqlMonitorSocket.DiscoverTcpPort (Int32 timeoutSeconds) System.Data.SqlClient.SqlConnection.DiscoverTcpPortViaSqlMonitor (System.String ServerName, System.String InstanceName) System.Data.SqlClient.SqlConnection.ParseDataSource (System.String theDataSource, System.Int32& thePort, System.String& theServerName) System.Data.SqlClient.SqlConnection.Open () ConnectToDB.Start () (at Assets/ConnectToDB.cs:33)
What am I missing?
Upvotes: 3
Views: 802
Reputation: 624
You can popular third-party solutions such as SmartFox Server or Photon if you need help establishing TCP/IP sockets.
Upvotes: 1