SQLテーブルにデータがあるかどうかをチェックするプロセスを作成しようとしています。
そして、存在するかどうかに応じて何かをしたいです。
だから、私はデータベースに接続するこのコードを持っていて、それは私がテーブルから取得したいデータを選択しています。
public List<MedidasAdoptar> leerMedidasAdoptar()
    {
        DataSet Datos = new DataSet();
        string connectionString = "Initial Catalog=MyDatabase;Data Source=MyServer;Integrated Security=false;User ID=SQLUser;Password=SQLPass;";
        string selectCommand =
            "SELECT [Número medida], [Cód_ Cliente], [Nombre Cliente], [Cód_ obra], [Nombre obra], Tipo, [Cód_ Medida], [Descripción Medida], [Respuesta Medida] FROM [MyDatabase$My table] " +
            "WHERE [Cód_ Cliente] = "+codigoCliente+" AND [Cód_ obra] = "+codigoObra;
        using (var MyConnection = new SqlConnection(connectionString))
        using (var MyDataAdapter = new SqlDataAdapter(selectCommand, MyConnection))
        {
            MyDataAdapter.SelectCommand.CommandType = CommandType.Text;
            MyDataAdapter.Fill(Datos);
            MyDataAdapter.Dispose();
            MyConnection.Close();
        }
        int i;
        //Right here (If it is possible) I want to determine if there is some data in table 
        try
        {
          //...doing some stuff
        } catch (SqlException e)
        {
            string msg = "";
            System.Console.WriteLine(msg);
            return new List<MedidasAdoptar>();
        }