I have a problem trying to connect to oracle database specifying the schema name, when the schema name is different than the user name.
I used to connect using the next String.
But in this case the Schema of the database was the same as the user name.
String con = "data source= (DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = " + host + ")(PORT = " + port + ")))(CONNECT_DATA =(SERVICE_NAME = " + servicename + ")));
USER ID=" + user + ";
PASSWORD=" + pass;
So the query for login was like
SELECT * FROM usuarios WHERE usuario='545478';
Now i have a new user for the conexion, diferent that the Schema, so now i need to change all the sql queries using the Schema name. For example if the schema name is PRODUCTION_DB the query needs to be change to:
SELECT * FROM PRODUCTION_DB.usuarios WHERE usuario='545478';
But I don't want to change all the queries in my code. I prefer to specified the database name in the connection like in MySQL.
How can I change the connection string to add the database name?
For example:
String con = "data source= (DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = " + host + ")(PORT = " + port + ")))(CONNECT_DATA =(SERVICE_NAME = " + servicename + ")));
USER ID=" + user + ";PASSWORD=" + pass;
DATABASE = "PRODUCTION_DB";
TnsNamesyou can still use this style in your app.Config or Web.Config I am currently using Oracle and it works this way.<connectionStrings> <add name="DbConn" connectionString=" Data Source=DataBaseName;User Id=xxx;Password=xxxx;"/>