First of all, it is generally not good practice to give direct access to the database on a mobile phone unless you have a very peculiar problem to solve. The ideal is usually that the mobile accesses a service on the network. This service would be hosted on a server with access to the database.
Other than that - you’re using the integrated security of Windows (Integrated Security=True;
). There is a very high probability (I would say 99,999 and a few nine percent more chance) that the user logged in to your mobile is not the same user logged in to the PC. I would even say that if it’s an iPhone, you’re logged in with an Apple account, and if it’s Android, the user logs in to Google, Facebook, or some other identity provider.
If you really want to log into the database with your phone (and I repeat that this is generally not recommended), you need to use another security scheme, such as one that asks for a username and password. You need to configure the database to accept authentication other than the one integrated with Windows, and you need to pass the username and password in the connection string.
Also make sure that your phone can reach the server over the network. Even though you are on the same network, the connection can be denied due to your settings (i.e.: firewall blocking port 1433 - your PC may not have this problem because it is the server itself - cellular not part of the domain/workgroup etc.).
@Lucasnunes, please don’t use
código
for given names (SQL). Batsticks should be used only for code and similar (filename, paths, Urls).– brasofilo
@Ok! It won’t happen again.
– Lucas Lima
When you say "published on the web," you mean IIS is on an external server, and you want it to access your local SQL Server? Your connection setting only works if IIS and SQL are on the same network.
– bfavaretto
No, the ISS is on my machine anyway. And all the devices that are accessing it are on the same network. However only the server itself can access all the functions that need access to the bank.
– Diego
What error does it make? Sure it is SQL?
– bfavaretto