.NET Oracle连接字符串

 In .NET2005,Web.config can't be created automatically.You add it by youself :right-click the solution's name,choose "Add New Item" ,then select "Web Configration File",at last,click the "Add" button.

The file is a little defferent from in .NET2003.

The question is how to use this file to connect to Oracle?

In .NET2003,you can add codes as followings do this:

 </system.web> 
 
 <appSettings> 
 <add key="PrintMode" value="Web"/>
 <add key="constring" value="Data Source=***;User=***;Password=***"/>
 <add key="databasetype" value="Oracle"/>
 
 </appSettings>

</configuration>

but in.NET2005 after you add them into the file,you will find an error like this "Error 1 各个节在每个配置文件中只能出现一次。有关异常的信息,请参阅帮助主题 <location>".

How to solve this problem?

I have got it.

Browse the web.config ,you will find two lines :

    <appSettings/>
    <connectionStrings/>

then delete these two lines.

And in your C# codes,when you want to use "constring" ,your code must be written like this:

OracleConnection conn = new OracleConnection(ConfigurationManager.AppSettings["constring"]);

Wish you good luck!

  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值