日期:2014-05-17  浏览次数:20497 次

求助!希望大家帮我解决几个问题!新手!
1、请问怎么从web.config中读出数据库的相关数据并连接数据库和执行数据库的相关操作?
  有一个web.config的示例代码(密码没有直接写上,而是加密过的。要读取后在解密,然后连接数据库):
XML code

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <section name="AppSettings" type="System.Web.Configuration.NameValueSectionHandler" />
    </configSections>
    <appSettings>
        <add key="jsfskg" value="" />
        <add key="MyConn" value="Data Source=abcd;pooling=true;min pool size=10;max pool size=300;User Id=12345;Password=" />
        <add key="MyPwd" value="Z%ML]V0692>A,"/> <!--value="fosf?0[J+t"/>-->
        <add key="HTTP_HOST" value="http://localhost" />
        <add key="APPL_PHYSICAL_PATH" value="f:\webserver\123\" />
        <add key="HTTP1" value="http://127.0.0.1" />
        <add key="HTTP2" value="http://127.0.0.1" />
        <add key="HTP" value="2" />
                <add key="AjaxSrc" value="/ajax/common.ashx" />
            <add key="AjaxSrc1" value="/ajax/zjdx.AjaxForm,zjdx.ashx" />
                <add key="cjlrurl" value="http://127.0.0.1/XkLuenceWeb/XkService.asmx?wsdl"/>
                <add key="glkg" value="1"/>
                <add key="glgbym" value=""/>
    </appSettings>
    <system.web>
                <httpHandlers>
                <add verb="POST,GET" path="ajax/*.ashx" type="Ajax.PageHandlerFactory, Ajax" />
            </httpHandlers>
        <compilation defaultLanguage="vb" debug="true" />
        <customErrors mode="RemoteOnly" defaultRedirect="123.htm" />
        <httpRuntime executionTimeout="1200" maxRequestLength="40960" />
        <authentication mode="Windows" />
        <authorization>
            <allow users="*" /> <!-- Allow all users  value="Data Source=12345;User Id=12345;Password=12345"-->
        </authorization>
<sessionState 
            mode="StateServer"            
            stateConnectionString="tcpip=127.0.0.1:42424"
            sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
            cookieless="false" 
            timeout="180" 
 />

        <globalization requestEncoding="GB2312" responseEncoding="GB2312" />
    </system.web>
</configuration>



2、这一句话什么意思?如果我在bin目录里找,要找哪个dll文件里面的哪些函数(我在网站目录里找不到default2.aspx.vb这个文件)?
VB.NET code
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="default2.aspx.vb" Inherits="zjdx.default2" enableViewState="False" %>


------解决方案--------------------
SQL:
<add name="SqlServer" connectionString="Data Source=服务器IP;Initial Catalog=数据库名;uid=用户名;pwd=密码;" providerName="System.Data.SqlClient"/>

Oracle:

<add name="OracleConnectionString" connectionString="Password=密码;User ID=用户名;Data Source=数据库名;Persist Security Info=True" providerName="System.Data.OracleClient"/>

sqlConn= ConfigurationManager.AppSettings["Sq