I am having a NullReferenceException while opening my connection in Windows Mobile 6.5. My code is like this:
SqlConnection conn = new SqlConnection("Data Source=.\\SQLEXPRESS;Initial Catalog=Company;Integrated Security=SSPI");
conn.Open();
I have tried this code in C# windows form application and its working but in windows mobile its not
Do you have an instance of SQLEXPRESS running on the mobile device? I suspect not but, even if you do, I don't believe you can use the name in the connection string, it's limited to the TCP/IP address and port.
You probably need to change your connection string so that it attempts to use the right location for the SQL server.
By way of example, if your server was running on the 10.5.5.5
machine at port 9999
, you would change:
Data Source=.\\SQLEXPRESS;...
to:
Data Source=10.5.5.5,9999;...