|
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
d_code.DropDownStyle = ComboBoxStyle.DropDownList Try conn.ConnectionString = "User Id=scott;Password=tiger;Data Source=orcl;" conn.Open()
cmd.Connection = conn cmd.CommandText = "select code,name from employee_1" rd = cmd.ExecuteReader
While (rd.Read) d_code.Items.Add(rd("code")) d_name.Text = rd("name") End While d_code.SelectedItem = d_code.Items.Item(0) 'コンボボックスにアイテムを表示させます。 Catch ex As Exception '例外が発生した場合 MessageBox.Show(ex.Message) 'メッセージを表示 Finally conn.Close() End Try
End Sub
因みに、上記の通り記述しました。
|