Oracle connection string helphttp://forums.asp.net/t/1800187.aspx/1?Oracle+connection+string+helpSun, 06 May 2012 01:35:33 -040018001874965833http://forums.asp.net/p/1800187/4965833.aspx/1?Oracle+connection+string+helpOracle connection string help <p>Hi,</p> <p>I have built a little web application that checks a field on an oracle database then redirect users depending on this value. I have just managed to deploy the admin are with a sql databse and thought all was well, but this is key to the functionality of the site.</p> <p>In my admin area I had to change the connection string for the sqlserverclient as the provider to make the site work, but I'm not sure what to do with the oracle bit.</p> <p>To explain how this works, basically I am using System.Data.Odbc in a model. This model contains the connection string and basically when called, performs the query on the oracle table and returns bool to the controller. The controller then directs the user to the correct view.</p> <p>This works fine when debugging on my machine but when I deploy the value is always to the defual &quot;false&quot; despite me changing the value on the oracle table so it would return true.</p> <p>Below is the model itself, I have also correctly setup the ODBC settings on the server and they connect to the database.</p> <p>I can't think what else it could be so I am guessing it is something to do with the connection string needing to be in the database?</p> <p>Any way here is my model:</p> <pre class="prettyprint">using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data; using System.Data.Odbc; namespace Gateway.Models { public static class Lock { static OdbcConnection conn = new OdbcConnection(); static OdbcDataAdapter da = new OdbcDataAdapter(); static DataSet ds = new DataSet(); static Boolean bol = false; static string val; public static bool getState() { string strSQL = &quot;SELECT TABLE.FIELD_LOCK.* FROM TABLE.FIELD_LOCK&quot;; goget(strSQL); if (bol == true) { val = ds.Tables[0].Rows[0][0].ToString(); if (val == &quot;Y&quot;) return true; return false; } else { return false; } } static void Conect() { conn.ConnectionString = &quot;DSN=database;UID=user;PWD=password;DBQ=database;DBA=W;APA=T;EXC=F;FEN=T;QTO=T;FRC=10;FDL=10;LOB=T;RST=T;GDE=F;FRL=F;BAM=IfAllSuccessful;MTS=F;MDI=F;CSR=F;FWC=F;PFC=10;TLO=0;&quot;; } public static void goget(string strSQL) { try { Conect(); da.SelectCommand = new OdbcCommand(strSQL); da.SelectCommand.Connection = conn; ds.Tables.Clear(); da.Fill(ds); if (ds.Tables[0].Rows.Count &gt; 0) { bol = true; } } catch // Unanticipated error. { bol = false; } }</pre> <p>Thanks in advance,</p> <p>Andy</p> <p>&nbsp;</p> 2012-05-04T14:27:01-04:004967334http://forums.asp.net/p/1800187/4967334.aspx/1?Re+Oracle+connection+string+helpRe: Oracle connection string help <p></p> <blockquote><span class="icon-blockquote"></span> <h4>mcinnes01</h4> <p></p> <pre class="prettyprint">static void Conect() { conn.ConnectionString = &quot;DSN=database;UID=user;PWD=password;DBQ=database;DBA=W;APA=T;EXC=F;FEN=T;QTO=T;FRC=10;FDL=10;LOB=T;RST=T;GDE=F;FRL=F;BAM=IfAllSuccessful;MTS=F;MDI=F;CSR=F;FWC=F;PFC=10;TLO=0;&quot;; }</pre> <p></p> </blockquote> <p></p> <p>HelloIt seems that you wanna change the connection string dynamicallySo please do to use the connection string by putting it into the web.config's &lt;connectionStrings&gt; tags by adding a nameand then use ConfiguationManager.ConnectionStrings[&quot;name defined in the connection string's tag&quot;].ConnectionString to read it out</p> <p>For more about ConfigurationManager's usageplease refer to this<a href="http://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager(v=vs.80).aspx">http://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager(v=vs.80).aspx</a></p> <p>Reguards</p> 2012-05-06T01:35:33-04:00