|  | 分類:[C#]
 
 下記のコードはSELECT文を発行し、その結果をdatasetに格納するというプログラムになっています。
 
 public void Test04()
 {
 SqlConnection connection = new SqlConnection();
 SqlCommand command = new SqlCommand();
 DataSet ds = new DataSet();
 
 // 接続文字列を設定します。
 connection.ConnectionString = @"Data Source=PC\SQLEXPRESS1;Initial Catalog=TestDatabase;User Id=sa;Password=sa;";
 
 using (SqlDataAdapter adapter = new SqlDataAdapter())
 {
 command.Connection = connection;
 command.CommandText = "SELECT * FROM m_syouhin";
 
 adapter.SelectCommand = command;
 
 // SQLを実行し結果をdsの中に格納します。
 adapter.Fill(ds);
 }
 }
 
 
 例えば既にデータベースのオブジェクトとして、viewが既にあったとします。名前はview1とすると、view1の内容をdatasetに格納する場合はどのようにおこなったらいいでしょうか?
 
 使用している言語は、c#になります。よろしくお願いします
 
 |