国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

如何在web.config中建立公用的的數據庫連接

2019-11-18 17:18:36
字體:
來源:轉載
供稿:網友

<configuration>
    <!-- application specific settings -->
    <appSettings>
        <add key=ConnectionString value=server=localhost;uid=sa;pwd=;database=store />
    </appSettings>
<configuration>

public SqlDataReader GetReviews(int PRoductID) {

    // 創建Connection和Command對象實例
    SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings[ConnectionString]);
    SqlCommand myCommand = new SqlCommand(ReviewsList, myConnection);

    myCommand.CommandType = CommandType.StoredProcedure;

    // 參數
    SqlParameter parameterProductID = new SqlParameter(@ProductID, SqlDbType.Int, 4);
    parameterProductID.Value = productID;
    myCommand.Parameters.Add(parameterProductID);

    // 執行
    myConnection.Open();
    SqlDataReader result = myCommand.ExecuteReader(CommandBehavior.CloseConnection);

    // 返回結果
    return result;
數據庫連接;return true>

 


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 彰化市| 启东市| 渝北区| 许昌县| 满城县| 冕宁县| 兴隆县| 高陵县| 元朗区| 桦川县| 宁波市| 丘北县| 仪征市| 连江县| 松江区| 大洼县| 保定市| 岫岩| 中山市| 开化县| 南宁市| 禄劝| 靖远县| 遵义县| 正蓝旗| 潜江市| 曲松县| 南郑县| 西盟| 鹤庆县| 青州市| 射洪县| 平凉市| 怀柔区| 陇南市| 通山县| 奇台县| 南城县| 旺苍县| 渝北区| 邻水|