0

Server Management Studio 2008 で Visual Studio 2010 を使用して、教師がすべての学年のすべての生徒の結果を確認できる機能を作成しました。

ドロップダウン選択により、グリッド ビューでデータが表示され、教師が Excel シートで選択内容を確認するためのボタンが表示されます。一部の選択では、データが多く、時間がかかります。

現在、私のクライアントは、ページにグリッド ビューを表示するのではなく、ドロップダウンの選択に基づいて Excel に直接エクスポートすることを望んでいます。

これを行うのを手伝ってくれる人はいますか..ページの読み込みが少し速くなりますか?

4

1 に答える 1

1

最初に ssms にストアド プロシージャを記述してデータを取得します。次のようになるはずです

   CREATE PROCEDURE [Retrieveresult] (@selectedfield nvarchar(50))
   AS  
   BEGIN  
   select * from students where condition=@selectfield
   END  

次にビジュアルスタジオで

   oConn = new SqlConnection();
   oConn.ConnectionString = "your connection string"
   SqlCommand command = new SqlCommand("Retrieveresult");
    command.CommandType = System.Data.CommandType.StoredProcedure;
     oConn.Open();
   command.Parameters.Add(new SqlParameter("@selectfield", System.Data.SqlDbType.nvarchar(50))); 
    command.Parameters["@selectfield"].Value="selected value from gridview"
   IDataReader oDr;
    oDr=command.executereader();
  while(oDr.read())
     {
       Get the corresponding values in the objects 
      }
于 2012-10-17T11:23:00.480 に答える