<구성>
<!-- 애플리케이션별 설정 -->
<앱 설정>
<추가 키=ConnectionString 값=서버=localhost;uid=sa;pwd=;database=store />
</app설정>
<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 매개변수ProductID = new SqlParameter(@ProductID, SqlDbType.Int, 4);
매개변수제품ID.값 = 제품ID;
myCommand.Parameters.Add(parameterProductID);
// 执行
myConnection.Open();
SqlDataReader 결과 = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
// 返回结果
결과 반환;
数据库连接;return true>