Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
278 views
in Technique[技术] by (71.8m points)

c# - oracle database connection in web.config asp.net

I know I can create a connection string in the c# class itself, but I am trying to avoid doing that. I want to create the connection in the web.config, which I read is more secure. Nevertheless I couldn't find any example that has the following attributes specified:

  • Host name
  • Port
  • SID
  • Username
  • Password
  • Connection Name

Could anyone help please with creating this in webconfig? I am connecting to oracle DB.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Here is the template:

     <connectionStrings>
        <add name="{ConnectionName}" 
        connectionString="Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=MyOracleSID)));User Id=myUsername;Password=myPassword;" 
        providerName="Oracle.DataAccess.Client"/>
     </connectionStrings>

Here is one of mine - minus a real TNS name and username and password:

    <add name="MSOL" connectionString="Data Source={TNS_NAME};User ID={username};Password={password};pooling=true;min pool size=5;Max Pool Size=60" providerName="Oracle.DataAccess.Client"/>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...