Вы разрабатываете приложение, которое будет подключаться к базе данных Microsoft SQL Server 2000 "Аэропорт". Получаемые данные будут заполнять элемент управления DataGrid при нажатии пользователем кнопки "btnFill". Выберите правильный фрагмент кода для получения этой функциональности:
(Отметьте один правильный вариант ответа.)
Варианты ответа
private void btnFill_Click(object sender, System.EventArgs e) { SqlConnection connection= new SqlConnection(ConnectionString);connection.Open(); SqlCommand command = new SqlCommand(); command.Connection = connection; command.CommandText = commandText; SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = command; DataSet dataset = new DataSet(); da.Fill(dataset, "Passenger"); dataGrid1.DataSource = dataset.Tables["Passenger"].Value; connection.Close(); }
private void btnFill_Click(object sender, System.EventArgs e) { SqlConnection connection= new SqlConnection(ConnectionString);connection.Open(); SqlCommand command = new SqlCommand(); command.CommandText = commandText; SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = command;da.Connection = connection; DataSet dataset = new DataSet(); da.Fill(dataset, "Passenger"); dataGrid1.DataSource = dataset.Tables["Passenger"].DefaultView; connection.Close(); }
private void btnFill_Click(object sender, System.EventArgs e) { SqlConnection connection= new SqlConnection(ConnectionString);connection.Open(); SqlCommand command = new SqlCommand(); command.Connection = connection; command.CommandText = commandText; SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = command; DataSet dataset = new DataSet(); da.Fill(dataset, "Passenger"); dataGrid1.DataSource = dataset.Tables["Passenger"].DefaultView; connection.Close(); }(Верный ответ)
private void btnFill_Click(object sender, System.EventArgs e) { SqlConnection Connection= new SqlConnection(ConnectionString);Connection.Open(); SqlCommand command = new SqlCommand(); command.Connection = connection; command.CommandText = commandText; SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = command; DataSet dataset = new DataSet(); da.Fill(dataset, "Passenger"); dataGrid1.DataSource = dataset.Tables["Passenger"].DefaultView; Connection.Close(); }
private void btnFill_Click(object sender, System.EventArgs e) { SqlConnection connection= new SqlConnection(ConnectionString);connection.Open(); SqlCommand command = new SqlCommand(); command.CommandText = commandText; SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = command;da.Connection = connection; DataSet dataset = new DataSet(); da.Fill(dataset, "Passenger"); dataset.DataSource = dataGrid1.Tables["Passenger"].DefaultView; connection.Close(); }