次のコードがあります
string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + txtFileLocation.Text;
using (DbConnection conn = new OleDbConnection(connectionString))
{
conn.Open();
DbCommand command = conn.CreateCommand();
string idfield = txtIDField.Text;
string picfield = txtPictureField.Text;
command.CommandText = "select " + idfield + ", " + picfield + " from " + selectedTable;
command.CommandType = CommandType.Text;
DbDataReader reader = command.ExecuteReader();
gridResults.DataSource = reader;
conn.Close();
}
接続文字列からわかるように、データベースはアクセスデータベースであり、提供されたデータベースも画像を添付ファイルとしてデータベースに保存します。
グリッドをロードするたびに、ランダムなものが表示されます:(例。
データベースの接続に慣れていないので、これは簡単な質問かもしれませんが、フォームで画像リストを有効にするにはどうすればよいですか?