国产探花免费观看_亚洲丰满少妇自慰呻吟_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>

 


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 都昌县| 鹿泉市| 湛江市| 邓州市| 厦门市| 缙云县| 门源| 江川县| 常熟市| 永城市| 大荔县| 酉阳| 乌兰县| 化隆| 龙山县| 漳平市| 东台市| 新闻| 屯门区| 禄丰县| 岢岚县| 得荣县| 通榆县| 剑阁县| 静安区| 麻江县| 广平县| 正阳县| 阳江市| 沙河市| 玉门市| 五常市| 南靖县| 临安市| 梁河县| 理塘县| 东辽县| 志丹县| 怀仁县| 北票市| 三门县|