EPAM Systems interview question

How to Connect data base in c#?

Interview Answer

Anonymous

25 June 2018

var resultDataSet = new DataSet(); using (var connection = new SqlConnection(connectionString)) { using (var sqlCommand = new SqlCommand { CommandType = commandType, CommandText = command, Connection = connection }) { connection.Open(); { using (var dataAdapter = new SqlDataAdapter(sqlCommand)) { dataAdapter.Fill(resultDataSet); } } }