I created a local database database.sdf and places it at the assets folder
and tried to connect to it
connectin string:
string connectionString =“Data Source=” + (System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)) + “\Database1.sdf;Persist Security Info=False”;
trying to open and use it
SqlConnection conn = new SqlConnection(connectionString);
string sqlIns = “INSERT INTO Shelf (row,colume,depth,shelfType,isEmpty) VALUES (@row, @colume, @depth, @shelfType, @isEmpty)”;
conn.Open();
try
{
SqlCommand cmdIns = new SqlCommand(sqlIns);
cmdIns.Parameters.AddWithValue(“@row”, shelf.row);
cmdIns.Parameters.AddWithValue(“@colume”, shelf.colume);
cmdIns.Parameters.AddWithValue(“@depth”, shelf.depth);
cmdIns.Parameters.AddWithValue(“@shelfType”, shelf.shelfType);
cmdIns.Parameters.AddWithValue(“@isEmpty”, shelf.empty);
cmdIns.ExecuteNonQuery();
cmdIns.Dispose();
cmdIns = null;
}
catch (Exception SockEx)
{
Debug.Log("Socket exception: " + SockEx.Message);
}
finally
{
conn.Close();
}
I get SocketException:
SocketException: לא מוכר מחשב מערך כזה.
System.Net.Dns.GetHostByName (System.String hostName)
System.Net.Dns.GetHostEntry (System.String hostNameOrAddress)
System.Net.Dns.GetHostAddresses (System.String hostNameOrAddress)
System.Net.Sockets.UdpClient.Connect (System.String hostname, Int32 port)
System.Net.Sockets.UdpClient…ctor (System.String hostname, Int32 port)
System.Data.SqlClient.SqlConnection+SqlMonitorSocket…ctor (System.String ServerName, System.String InstanceName)
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 ()
(wrapper remoting-invoke-with-check) System.Data.SqlClient.SqlConnection:Open ()
consol_manager.isShelf_empty (Int32 row, Int32 colume, Int32 depth) (at Assets/Scripts/consol_manager.cs:177)
setEmptyTrays.Awake () (at Assets/Scripts/setEmptyTrays.cs:23)
unrecognized host
tried spacifing direct address and it want work
I googled and found that to use the sdf file I should use SqlCeConnection but its not on system.data
any help?