Question

I use ASP.NET for web and Oracle for the database. For communicating between ASP.NET and Oracle I use ODP.NET. I have specified the connection string in web.config file as such:

  <connectionStrings>
    <add name="main" connectionString="Data Source=AGAPUSTEST; User Id=agapus;Password=pswd;"/>
  </connectionStrings>

When I try to establish connection using this connection string I get "Integrated Security is an invalid connection string attribute" error. As you can see I have not specified this attribute in the configuration file. So at some point this attribute probably gets added automatically. I used to have the connection string hard coded and I didn't have any problems at all. Do you have any ideas how to solve this?

Was it helpful?

Solution

Luckily I have found the solution. I'd provided the web config content but I had not given you the code I use to access the connection string from code behind. Here's the code:

string conString = ConfigurationManager.ConnectionStrings[0].ConnectionString;

As I was suspecting Integrated Security attribute being added automatically I was almost sure that some other connection string was retrieved. I tired changing ConnectionStrings[0] to ConnectionStrings["main"] and voila, it worked. So although there's only one connection string in the configuration file, the 0th one is not the one I needed. When I displayed the 0th connection string look what I got:

data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true

I'm sure you guessed where it comes from, from the machine.config file. So to make everything clean and safe I've once more been convinced that accessing by name is most of the time a better idea.

OTHER TIPS

Looks like they are talking about this problem here: https://community.oracle.com/thread/585813?tstart=405

Seems the solution could be to use User Id=/ in the connection string and see if that works

Also make sure to have your sqlnet.ora have "SQLNET.AUTHENTICATION_SERVICES = (NTS)"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top